Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forwarding VIRTUAL_HOST to other containers in docker-compose.yml #253

Closed
georgediaz88 opened this issue Oct 8, 2015 · 2 comments
Closed

Comments

@georgediaz88
Copy link

I'm using a docker-compose.yml to run my web app and have brought in nginx-proxy as a container:

# docker-compose.yml

nginxproxy:
   restart: always
   image: jwilder/nginx-proxy
   volumes:
     - /var/run/docker.sock:/tmp/docker.sock:ro
   ports:
     - "80:80"

web:
  build: .
  command: ./script/start_docker
  environment:
    VIRTUAL_HOST: app.docker
    VIRTUAL_PORT: 3000
  ports:
    - "3000:3000"
    - "3010:3010"
  links:
    ...

other-container:
  ...
  ^^ can't reach app.docker:3000

This works fine and is reachable by my web app container if I pass a VIRTUAL_HOST=app.docker and VIRTUAL_PORT=3000. However, in other containers, where I'd like to reach the VIRTUAL_HOST, I can't. Even in my "web" container I can't curl by the VIRTUAL_HOST. Any ideas how to make the VIRTUAL_HOST available on my other containers? Do I need to pass VIRTUAL_HOST for every container? I'm still unsure. Any help would be appreciated. Thanks.

@jwilder
Copy link
Collaborator

jwilder commented Oct 8, 2015

You need to send the request from your other containers to your nginxproxy container's port 80 and specify the correct Host header. You could probably specify some extra_hosts config options to your other containers to create hosts entry for app.docker <your host ip>. You could also look at: http://engineering.ifttt.com/oss/2015/10/06/developing-with-docker/ which uses dnsmasq to handle DNS resolution locally.

@georgediaz88
Copy link
Author

@jwilder thanks for response.

Okay, that makes sense. It seemed I was missing a step somewhere. It was almost too easy ;). I'll take a look at both solutions. Thanks.

Alexander-Krause-Glau pushed a commit to Alexander-Krause-Glau/rpi-docker-nginx-proxy that referenced this issue Mar 30, 2018
Added jenkins nginx letsencrypt example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants