Caddy v2 web-server config for Nextcloud 20

1. Caddy version (caddy version):

2.2.1

2. How I run Caddy:

Via caddyfile

a. System environment:

OS: CentOS

b. Command:

c. Service/unit/compose file:

d. My complete Caddyfile or JSON config:

nextcloud {
   root * /var/www/nextcloud
   encode gzip zstd
   file_server
   php_fastcgi unix//run/php-fpm/www.sock {
#      env front_controller_active true
   }
#   header {
#      Strict-Transport-Security max-age=31536000;
#   }
#   redir /.well-known/carddav /remote.php/dav 301
#   redir /.well-known/caldav /remote.php/dav 301
#   @forbidden {
#      path /.htaccess /data/* /config/* /db_structure /.xml /README /3rdparty/* /lib/* /templates/* /occ /console.php
#   }
#   respond @forbidden 404
}

3. The problem I’m having:

I am trying to use caddy as a webserver for Nextcloud. Hopefully this is common enough that others are familiar with the required configuration.

The problem I am facing is that whenever I try to login, it kicks me back to the starting page instead of logging in or saying that credentials are wrong. Using Apache server this problem does not occur

4. Error messages and/or full log output:

No clear error message.

5. What I already tried:

Uncommenting any of the other options in the linked Caddyfile

6. Links to relevant resources:

Original nextcloud migration topic

I don’t see anything wrong with your config, it aligns with others like the one in this post:

@basil got any ideas?

php_fastcgi unix//run/php-fpm/www.sock assumes you’re using a Unix socket. If you’re using a TCP port try php_fastcgi 127.0.0.1:9000.

1 Like

That was not the issue, but now I’ve got it working. I am not sure if this was the actual issue, but these are the only changes I’ve made which got it working again:

  • Create a new group to encapsulate all the different web-servers I have
  • In /etc/php-fpm.d I’ve created a few pools for caddy and other webservers, with respective user and group
  • Changed the group ownership of /var/lib/php/{session,wsdlcache,opache} and /var/log/php-fpm to the above created group so that all sockets have write privileges there

It might be only the last part that was giving me issues, but there were no apparent console errors to indicate that.

1 Like

Most likely in /var/log/php-fpm.log

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.