I'm using the setup under .examples/docker-compose/with-nginx-proxy/mariadb/fpm/ but using my own instance of nginx-proxy and lets-encrypt-companion. The setup for both of those are practically identical to what is in the docker-compose.yml in this example so I took them out. My current docker-compose.yml is currently this:
version: '3'
services:
db:
build: ./db
restart: always
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=
env_file:
- db.env
app:
image: nextcloud:fpm
restart: always
volumes:
- nextcloud:/var/www/html
environment:
- MYSQL_HOST=db
env_file:
- db.env
depends_on:
- db
web:
build: ./web
restart: always
volumes:
- nextcloud:/var/www/html:ro
environment:
- VIRTUAL_HOST=
- VIRTUAL_PORT=80
- LETSENCRYPT_HOST=
- LETSENCRYPT_EMAIL=
expose:
- "80"
depends_on:
- app
networks:
- nginx-proxy
volumes:
db:
nextcloud:
certs:
vhost.d:
html:
networks:
nginx-proxy:
external: true
It seems that i can start the containers without issue and they all show up under docker container ls but upon attempting to open the nextcloud page I receive a 502 bad gateway error and in the logs for the app container I see the error nginx: [emerg] host not found in upstream "app:9000" in /etc/nginx/nginx.conf:31. The nginx.conf file has not been changed at all. Has anyone else had this issue?
I also had this issue. Have you tried to restart your proxy? nginx does not check the ip of the application container after nginx has started. So if the application conatiner gets a new ip your proxy still tries to connect to the old ip. That was the problem in my case.
I just had the same issue.
I only added the default network to the web service and it finally worked.
@Morgy93 gave the right answer.
You have to make sure, that the nextcloud-fpm container (app) and the webserver (web) share the same network. Docker compose implicitly adds a network called default to all containers as long as there is none otherwise specified.
The web container has also to be in the proxy network, so that outside connections can reach the service.
Since you have specified a network, you have to manually add the default network to the container.
...
web:
build: ./web
restart: always
volumes:
- nextcloud:/var/www/html:ro
environment:
- VIRTUAL_HOST=
- VIRTUAL_PORT=80
- LETSENCRYPT_HOST=
- LETSENCRYPT_EMAIL=
depends_on:
- app
networks:
- nginx-proxy
- default
...
Most helpful comment
@Morgy93 gave the right answer.
You have to make sure, that the nextcloud-fpm container (app) and the webserver (web) share the same network. Docker compose implicitly adds a network called default to all containers as long as there is none otherwise specified.
The web container has also to be in the proxy network, so that outside connections can reach the service.
Since you have specified a network, you have to manually add the default network to the container.