Nextcloud with docker-compose and external nginx proxy

I have a docker-compose setup for my blog (nginx+node-js) now I’d like to add nextcloud.

This means I have an existing docker-compose and have nginx running in the host ubuntu. The existing docker-compose.yml file has only the blog’s node-js server. The nginx server has lets-encrypt setup for all of the services that it proxies, domain.com (my blog) and cloud.domain.com (where I’d like to put nextcloud).

The proxies are all working correctly but now I need to get nextcloud up by adding it to my docker-compose. Most how-tos also include the webserver/proxy and so seem to hide config by assuming the proxy is running inside the docker-compose network, it is not in my case. The nginx server is running on bare Ubuntu.

What is the minimal setup for nextcloud (fpm server ready for an existing nginx proxy) + db (maria + redis or any other is fine with me). What port does the docker-compose nextcloud expose to the proxy and how? I think I need to map the nextcloud-fpm container port to a host port, how?

What is the integration needed in my nginx proxy setup? For instance what port should all trafic be sent to for the docker-compose nextcloud server?

Simply bring nextcloud up and expose Ports in your yaml file:

    ports:
      - 80:8000
#      - 443:8001 #I think you will use http only behind the proxy

And than you can configure ngnix reverse proxy to this specific port. E.g. to 8000 as in example above.

There are also few examples in official docker repository. Did you check them?

Hmm, still not working.

What is the native Nginx proxy config for use with the docker-compose Nextcloud FPM server?

I’m using this config for the Nginx proxy: https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html#nextcloud-in-the-webroot-of-nginx

But I get a ERR_TOO_MANY_REDIRECTS. I have tried clearing cookies and accepting all cookies but still get the error.

Is anyone using this config?

Argh, the redirects were caused by config that certbot added. I’ve strripped that all out now and just running with HTTP for now.

I get a BAD GATEWAY message from Nginx.

Not sure if that config for Nginx is meant to work with a docker nextcloud:fpm container.

Does anyone have a docker-compose.yaml or nginx config for host based nginx and container nextcloud?