Monthly Archives: March 2019

Troubleshooting nextcloud running on lighttpd

For historic reasons my personal nextcloud runs on lighttpd. (In fact I started in 2014 with ownCloud on Debian 8 (Jessie) and never changed the webserver.) This works, although it is not a first citizen supported platform, but after all nextcloud just needs some PHP/MySQL, so the webserver should not matter, should it?

After upgrading to nextcloud 15 and installing the social app/plugin, I got some warnings about missing rewrites/redirects. So it seems there are some new rewrites for service discovery in town, you can learn about those on the troubleshooting page of the administration manual.

You get config snippets for Apache and nginx (which are by far the most used webservers, I don’t blame nextcloud for not giving advise on every exotic webserver out there). For lighttpd you have to do it on your own and this is what I came up with. Load mod_redirect and mod_rewrite in your main lighttpd.conf and for the nextcloud config add this:

        # for social app
        # TODO  After upgrade to lighttpd > 1.4.50 revisit
        #       https://redmine.lighttpd.net/projects/1/wiki/docs_modrewrite
        url.rewrite-once = (
                # Match when there are no query variables
                "^/.well-known/webfinger$" => "/public.php?service=webfinger",
                # Match query variables and append with &
                "^/.well-known/webfinger\?(.*)$" => "/public.php?service=webfinger&$1"
        )

        url.redirect = (
                "^/.well-known/caldav$" => "/remote.php/dav",
                "^/.well-known/carddav$" => "/remote.php/dav"
        )

If you installed in a subfolder (the subfolder is still called owncloud here, adapt if needed):

        # for social app
        # TODO  After upgrade to lighttpd > 1.4.50 revisit
        #       https://redmine.lighttpd.net/projects/1/wiki/docs_modrewrite
        url.rewrite-once = (
                # Match when there are no query variables
                "^/owncloud/.well-known/webfinger$" => "/owncloud/public.php?service=webfinger",
                # Match query variables and append with &
                "^/owncloud/.well-known/webfinger\?(.*)$" => "/owncloud/public.php?service=webfinger&$1"
        )

        url.redirect = (
                "^/owncloud/.well-known/caldav$" => "/owncloud/remote.php/dav",
                "^/owncloud/.well-known/carddav$" => "/owncloud/remote.php/dav"
        )

For the future I consider changing the webserver, because lighttpd is not recommended by SabreDAV, which is used by nextcloud. But that’s not decided yet, for today this is it.