How to use nextcloud container with existing nginx container?

Hi, I’m new to docker and was wondering how can I use nextcloud container if I already have nginx container? Can the nextcloud container use the nginx in my already existing nginx container? same with the database? or the only thing I can do is change the port on my nextcloud and on my nginx make a proxy pass to the new port? Thanks

Our nextcloud image already has nginx and is designed to be used with that. But you can reverse proxy that via another nginx instance like we do here: https://docs.linuxserver.io/general/swag#nextcloud-subdomain-reverse-proxy-example

@aptalca Correct me if I’m wrong – nextcloud requires a webserver such as nginx (or is really nginx in this situation just a reverse proxy??).

Am I correct in my thinking you could stack nginx (#1)->nginx (#2)->nextcloud where nginx #1 is the reverse proxy and nginx #2 is the webserver?

Correct. The nginx built in is used as a web server as nextcloud is just a php app.

You can then use our swag image (nginx based) as a reverse proxy in front of it

how to properrly to configure those nginx?
everything will be run on same server.

scenario one

nginx #1 is:

  • handling several subdomains but there is nextcloud.mydomain
  • also it is listen 80 and 443
  • configuration for nextcloud.mydomain is that it will redirect 80 to 443
  • all trafic will be forwarde to localhost:8043

nginx #2 is

  • listening only 443 but docker will expose that as 8043 on server localhost

so both nginx has to share same certificates?
how to configure nginx #1?
I see advantege that all critical config is done in nginx #2 and I trust to LSIO they are doing it more better then me.

scenario two

nginx #2 will handle only http on port 8080
disadvantage is that I have to configure nginx #1 correctly and safely. I am afraid that I am not good enough in it.

thanks