Open blicknix opened 6 months ago
The image, as distributed, isn't really set up to do this in any official manner. I'm not saying a sub-directory setup can't be made to work, but you'd be on your own.
Have you considered using a virtual host / subdomain instead? It doesn't even require another IP address if you don't want it to. eg. https://github.com/nextcloud/docker/issues/1992#issuecomment-1859247819
The problem with your setup (and with the referenced configuration in combination with this Docker image and sub-paths in general) is the combination of the document root, the fastcgi param SCRIPT_FILENAME
and the path where the Nextcloud files are located within the FPM Docker container (which is /var/www/html
, not /var/www/nextcloud
).
You are using /var/www
as document root in your nginx config and web container. With this, the web container can correctly process requests to static assets under the /nextcloud sub-path. However, the web container passes all requests to php files via the SCRIPT_FILENAME
fastcgi param as /var/www/nextcloud/some-path/some-file.php
. The files within the FPM container however are located inside /var/www/html
so it can't find the file and returns a 404 error.
I think you somehow have to cut out or rewrite the /nextcloud
sub-path string that is passed as SCRIPT_FILENAME
to the FPM container, but I don't know how this is done. Another hack could be symlinking /var/www/nextcloud
to /var/www/html
inside the container, but I don't know if this plays well with Nextcloud / FPM in general.
A simpler alternative if you don't want to mess around with the Nginx config would be using the Apache-based Docker image behind your Nginx reverse proxy. Your reverse proxy would then only need to have one location block for /nextcloud
that forwards the requests to /
of the Apache-based container. And the container should have the OVERWRITEWEBROOT
env-var set to /nextcloud
I guess.
We try to run the fpm image in a sub directory with the config for the nginx proxy from the config from the nextcloud documentation. While everything works with no sub directory, we get 404 from the app container as the scripts are tried to be accessed from with the sub directory attached. We tried to change the parameters for overwritewebroot and the other overwrite parameters, but nothing helped with this issue.
Docker compose
nginx.conf
Logs for app container