0

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.

1 Answer 1

1

I can't see your problem, but I can give some advices.

  1. Mount of vhostd
    You have a mount vhostd:/etc/nginx/vhost.d. If you have settings in there, then you should share them with us.
    If not, then just remove the mount.

  2. Multidomain pattern
    You specified multiple domains in a different pattern as jwilder/nginx-proxy.
    Instead of VIRTUAL_HOST=domain1.com www.domain1.com you should write VIRTUAL_HOST=domain1.com,www.domain1.com.
    See jwilder/nginx-proxy, chapter "Multiple Hosts"

Sign up to request clarification or add additional context in comments.

8 Comments

Great! I have written a comma like you point out and it works. I don't have settings in vhostd, so I have removed it. Thanks, akop.
When I write docker-compose up -d and visit my domains, the apps are running. After that, if I don't click tabs the apps appear inactive, I woud say sleeping. I would like to know how to fix this and see the apps always active.
Docker will not put apps into a "sleep state". I don't know shiny, maybe there a logic like this.
I think it's nginx. About 1 minute after visiting my domain without clicking tabs, the domain appears idle, like a session timed out, and the screen color changes. I would like to know if there is a way to set this in docker compose, something like NGINX_TIMEOUT=30 minutes.
nginx is only acting as proxy, it will never change your app. If the screen-color changing, it must be come from shiny.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.