The following can be used to allow pretty URLs:
url.rewrite-if-not-file = ( "^/nextcloud/([^.]+)/?$" => "/nextcloud/index.php/$1" )
€: Breaks at least updater, which needs to be taken out from this rewrite, similar to what is done in official Nginx config: https://docs.nextcloud.com/server/stable/admin_manual/installation/nginx.html
Properly more issues, since if-not-file
does not work as expected: "^/nextcloud/(.+)/?$"
leads to remote.php
requests (files/activity list) being rewritten/blocked somehow, only "^/nextcloud/([^.]+)/?$"
works, which explicitly excludes URL with dots inside. But since it does not reliable detect remote.php
existence, it might break other things as well, or you need to define rewrites separately for all dirs/file types, similar to what is done in Nginx config above.
mod_rewrite
needs to be enabled:
lighttpd-enable-mod rewrite
or
server.modules += ( "mod_rewrite" )
somewhere in Lighttpd config, if above command does not work on your system.
But does not work with this, in comparison with Apache .htacces/rewrite base solution or Nginx config from docs with enabled front controller:
- The links inside Nextcloud web UI always revert the pretty URLs. Not sure how to enable Nextcloud to use pretty URLs internally as well, since on Nginx this is the automatically just via webserver config.
- App store does not open with pretty URL, just blank page. I guess has something to do with Nextcloud internally using non-pretty URLs and
/settings/apps
is also contained when accessing a certain apps page (files, activity, …). my.domain.org[/nextcloud]/apps/files/
e.g. is redirected to default app, where the rewrite rule should actually rewrite it to /index.php/settings/apps
(app store). So Nextcloud internal rewrite/redirects somehow break this. Investigating…
Enable referrer policy:
setenv.add-response-header = ( "Referrer-Policy" => "no-referrer" )
Requires mod_setenv:
server.modules += ("mod_setenv" )
€: NC15 ships this header internally now it seems. Adding it leads to warning on admin panel (I guess since set doubled), removing it resolves the warning. Not sure why on Apache, it is added via .htaccess
as well then without issues. In Nginx config from docs, it is added, but removed from PHP scripts via: fastcgi_param modHeadersAvailable true;
?
I ended up now using the following config for Lighttpd, which includes security hardenings from default .htaccess respectively Nginx config from docs:
$HTTP["url"] =~ "^/nextcloud($|/)" {
# Hardening
# - Directories
$HTTP["url"] =~ "^/nextcloud/(build|tests|config|lib|3rdparty|templates|data)($|/)" { url.access-deny = ("") }
# - Files
$HTTP["url"] =~ "^/nextcloud/(\.|autotest|occ|issue|indie|db_|console)" { url.access-deny = ("") }
# - Directory listing
dir-listing.active = "disable"
# - Cache control and security headers for static resources
$HTTP["url"] =~ "^/nextcloud/\.(css|js|woff2?|svg|gif)$" {
setenv.add-response-header += (
"Cache-Control" => "public, max-age=15778463",
"X-Content-Type-Options" => "nosniff",
"X-XSS-Protection" => "1; mode=block",
"X-Robots-Tag" => "none",
"X-Download-Options" => "noopen",
"X-Permitted-Cross-Domain-Policies" => "none",
"Referrer-Policy" => "no-referrer",
)
}
}