Nextcloud Caddy


(Jan Schröder) #1

Hi,

I want to run nextcloud with caddy.
But I get the following errors:

[INFO] 81.169.154.213 - No such site at :80 (Remote: 191.205.76.56, Referer: )
 [INFO] Scanning for stale OCSP staples
[INFO] Done checking OCSP staples
 http: TLS handshake error from 91.6.20.75:56051: tls: no certificates configured

What I have to do now?

Best Regards


(Matthew Fay) #2

Hi @Level_3_Mage, welcome to the Caddy community.

Are these errors stopping you from browsing to your site?


(Jan Schröder) #3

I got a 404 from caddy and it seems I have an certificate but when I call my website with “/nextcloud” I get an 500 error.


(Matthew Fay) #4

Hmm. Can you share your Caddyfile?

Does the URL in your browser’s address bar exactly match the site label in your Caddyfile?


(Jan Schröder) #5
levelthreemage.de/nextcloud {

        root   /var/www/html/nextcloud
        log    /var/log/nextcloud_access.log
        errors /var/log/nextcloud_errors.log

        fastcgi / 127.0.0.1:9000 php {
                env PATH /bin
        }

        header / {
                 Strict-Transport-Security         "max-age=15768000;"
        }

        # checks for images
        rewrite {
                ext .svg .gif .png .html .ttf .woff .ico .jpg .jpeg
                r ^/index.php/(.+)$
                to /{1} /index.php?{1}
        }

        rewrite {
                r ^/\.well-known/host-meta$
                to /public.php?service=host-meta&{query}
        }
        rewrite {
                r ^/\.well-known/host-meta\.json$
                to /public.php?service=host-meta-json&{query}
        }
        rewrite {
                r ^/\.well-known/webfinger$
                to /public.php?service=webfinger&{query}
        }

        rewrite {
                r ^/index.php/.*$
                to /index.php?{query}
        }

        # client support (e.g. os x calendar / contacts)
        redir /.well-known/carddav /remote.php/carddav 301
        redir /.well-known/caldav /remote.php/caldav 301

        # remove trailing / as it causes errors with php-fpm
        rewrite {
                r ^/remote.php/(webdav|caldav|carddav|dav)(\/?)(\/?)$
                to /remote.php/{1}
        }

        rewrite {
                r ^/remote.php/(webdav|caldav|carddav|dav)/(.+?)(\/?)(\/?)$
                to /remote.php/{1}/{2}
        }

        rewrite {
                r ^/public.php/(dav|webdav|caldav|carddav)(\/?)(\/?)$
                to /public.php/{1}
        }


        rewrite {
              r ^/public.php/(dav|webdav|caldav|carddav)/(.+)(\/?)(\/?)$
                to /public.php/{1}/{2}
        }

        # .htaccess / data / config / ... shouldn't be accessible from outside
        status 403 {
                /.htaccess
                /data
                /config
                /db_structure
                /.xml
                /README
        }

}

Yes it match.


(Matthew Fay) #6

If that’s your entire Caddyfile, then:

  1. The 404s are generated because Caddy has no site definition for levelthreemage.de - it only has a definition for levelthreemage.de/nextcloud, and;

  2. I’d wager that the 500s are linked to the fact that you’re putting Nextcloud in a subfolder. I believe you can configure an overwrite of the web root, but you’d need to look at the Nextcloud documentation. You might not need to fiddle with the rewrites, but I’m not 100% sure.

My strong suggestion is to drop the path from the site label (i.e. levelthreemage.de/nextcloud -> levelthreemage.de) and see if that solves the 500 series errors (I fully expect it to solve the 404s). If it does, you’ll know that the obstacle is figuring out how to get Nextcloud to play nicely under the subfolder.


(Jan Schröder) #7

I changed it from levelthreemage.de/nextcloud to levelthreemage.de on Caddyfile but that changed nothing.
So I changed it back and after delete the php7.0-fpm that the server only can use the 7.2 version I’m now getting a BadGateway. The Errorlog says [ERROR 502 /] dial tcp 127.0.0.1:9000: connect: connection refused.


(Matthew Fay) #8

So after changing the site label and reloading Caddy, you were still getting 404s when loading the main page?

As for the error log, it’s possible the new version of PHP doesn’t have FPM listening on port 9000.


(Jan Schröder) #9

After changing it to the main page and changing it back I get a 421 error.

And now I have to change the version of PHP that PHP can listen to Port 9000?


(Jan Schröder) #10

I’ve done it!

I had more than one PHP version so I deleted everything except the version I needed (PHP7.2) than I reinstalled php7.2-fpm and changed in the www.conf file to listen=127.0.0.1:9000

Just write that if anyone else have the same issue. This may helps!