I have two apps (app1 and app2) and I would like to run them on my domains (domain1 and domain2). I use docker containers to do this and a docker reverse proxy. If I run each docker app independently, they work well. When I execute docker-compose up -d and I visit my domains, I can see the following message: Welcome to nginx!. I can't see my apps running.
My docker-compose.yml is the following:
version: "3.7"
services:
proxy:
image: jwilder/nginx-proxy
container_name: proxy
labels:
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
ports:
- "80:80"
- "443:443"
volumes:
- certs:/etc/nginx/certs
- vhostd:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt
environment:
- NGINX_PROXY_CONTAINER=proxy
volumes:
- certs:/etc/nginx/certs
- vhostd:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock
app1:
image: app1_image
container_name: myapp1
expose:
- "9090"
environment:
- VIRTUAL_PORT=9090
- VIRTUAL_HOST=domain1.com www.domain1.com
- LETSENCRYPT_HOST=domain1.com www.domain1.com
- [email protected]
volumes:
- /srv/shiny-server/app1/app/data:/srv/shiny-server/app1/app/data
app2:
image: app2_image
container_name: myapp2
expose:
- "8080"
environment:
- VIRTUAL_PORT=8080
- VIRTUAL_HOST=domain2.com www.domain2.com
- LETSENCRYPT_HOST=domain2.com www.domain2.com
- [email protected]
volumes:
- /srv/shiny-server/app2/app/data:/srv/shiny-server/app2/app/data
volumes:
certs:
html:
vhostd:
If I don't use the detach mode and I execute the docker containers, I get the following error:
$ docker-compose up
myapp1 | Listening on http://0.0.0.0:9090
myapp2 |
myapp2 | Listening on http://0.0.0.0:8080
...
proxy | nginx.1 | myserverIP - - [16/Aug/2022:17:33:01 0000] "GET /favicon.ico HTTP/1.1" 404 153 "http://www.domain1.com/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0" "-"
proxy | nginx.1 | 2022/08/16 17:33:01 [error] 25#25: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: myserverIP, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "www.domain1.com", referrer: "http://www.domain1.com/"
...
proxy | nginx.1 | myserverIP - - [16/Aug/2022:17:33:46 0000] "GET /favicon.ico HTTP/1.1" 404 153 "http://www.domain2.com/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0" "-"
proxy | nginx.1 | 172.25.0.1 - - [16/Aug/2022:17:33:52 0000] "GET / HTTP/1.1" 200 615 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0" "-"
proxy | nginx.1 | 2022/08/16 17:33:52 [error] 25#25: *6 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.25.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "domain2.com", referrer: "http://domain2.com/"
I don't know if this error is causing the problem, buy I just see on my domains: Welcome to nginx! I can't see my apps running.
CodePudding user response:
I can't see your problem, but I can give some advices.
Mount of vhostd
You have a mountvhostd:/etc/nginx/vhost.d
. If you have settings in there, then you should share them with us.
If not, then just remove the mount.Multidomain pattern
You specified multiple domains in a different pattern asjwilder/nginx-proxy
.
Instead ofVIRTUAL_HOST=domain1.com www.domain1.com
you should writeVIRTUAL_HOST=domain1.com,www.domain1.com
.
See jwilder/nginx-proxy, chapter "Multiple Hosts"