docker icon indicating copy to clipboard operation
docker copied to clipboard

Nginx-proxy: Howto server multiple Sites on one host? (Nextcloud in subdirectory)

Open obel1x opened this issue 2 years ago • 4 comments

At https://github.com/nextcloud/docker/tree/master/.examples#with-nginx-proxy it is written "The proxy is designed to serve multiple sites on the same host machine." Thats fine - but: could somebody pls. explain how and document it there?

What should be explained:

  • Where to set which settings to get Nextcloud running in some subdirectory (e.g. "/nextcloud" on the server) for that proxy- setup? (As far as i have understood, with the proxy setup, nextcloud itself would be running without subpage and on port 80 internally, but the reverse proxy should map redirect external requests to ssl and map the subdirectory?)
  • How to add other services? lets say another webservice on port 80 proxied to "https://sameserver.site/website" over that proxy:
web_nginx:
  image: nginx
#  ports:
#  - "80:80"
  • maybe a hint how to do redirect to one of the pages by proxy configuration by default?

saw some issues related to this. Am opening a new ticket, as the issues i found were about running nextcloud in some subfolder itself without proxy but doing it in a dangerous way. would like to find a working solution for this to close issues #401 and #1919

obel1x avatar May 27 '23 05:05 obel1x

The reverse proxy image here is merely the nginx-proxy image.

https://hub.docker.com/r/nginxproxy/nginx-proxy

https://github.com/nginx-proxy/nginx-proxy

The only customization made in the Dockerfile here is the addition of NC specific upload parameters:

https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/proxy/Dockerfile

This doesn't necessarily address your query, but it may be a starting point.

joshtrichards avatar May 28 '23 11:05 joshtrichards

@joshtrichards thank you. That basically works - but i do think there is bug in Nextcloud what makes this setup impossible right now.

what i am doing:

  1. clone this repo
  2. copy files from https://github.com/nextcloud/docker/tree/master/.examples/docker-compose/with-nginx-proxy/postgres/fpm to some nice place
  3. do the things on https://github.com/nextcloud/docker/tree/master/.examples#with-nginx-proxy
  4. start nextcloud+nginx-proxy with docker-compose up -d
  5. setup nextcloud with proxy and letsencrypt -> works like a charme
  6. now docker-compose down
  7. add virtual_path=/nextcloud and virtual_dest=/ in yaml, web
  8. in nextcloud_data config.php set overwritehost, overwriteprotocol, overwritewebroot, overwrite.cli.url as described in nextcloud- docs
  9. start nextcloud back again doing occ / update .htaccess

That works: Nextcloud starts from subdirectory - BUT it will not serve Files.

The Error in NC- Log is "Requested uri (/nextcloud/remote.phpp/webdav) is out of base uri (/nextcloud/remote.php/webdav/)" -> so i guess the values of config.php are somewhat messing around.

i am currently setting up a developement-environement to inspect whats going on. This one is nasty, as a small bug (i hope) is preventing that perfect functionality.

if you have any hints concerning that bug, i would be very greatful for any help.

obel1x avatar May 28 '23 18:05 obel1x

Late on the party, but i think i know where your problem is . The example you used above have a custom nginx conf for the web container, you need to edit that conf file to properly serve the uri-s. Post that nginx.conf(/path/to/whatever/fpm/web/nginx.conf) and i might help you where the problem is.

tzerber avatar Dec 15 '23 11:12 tzerber

Thanx, yes that may be the problem here . i thougth thats what the parameter virtual_path and virtual_dest in yml should be for at nginx.

Well i have gone further and am now using subdomains aka nextcloud.hostname.com. I realised that service2.hostname.com works better and is the intended way to do so. For some newby in hosting that may be a worth a word to understand that services should be seperated via subdomains rather than url-paths, To point that out is all i would suggest here.

I would close this one.

obel1x avatar Dec 17 '23 18:12 obel1x