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

Problem with two expose ports #1066

Closed
flomsk opened this issue Feb 13, 2018 · 3 comments · Fixed by #2434
Closed

Problem with two expose ports #1066

flomsk opened this issue Feb 13, 2018 · 3 comments · Fixed by #2434
Labels
kind/feature-request Issue requesting a new feature scope/multiport Issue or PR related to multi port proxying

Comments

@flomsk
Copy link

flomsk commented Feb 13, 2018

Hello there!
I have a docker app that exposes two ports.
So my compose config is

  test-app:
    build: test-app
    restart: on-failure
    entrypoint: /root/start.sh
    volumes:
      - /etc/localtime:/etc/localtime:ro
    expose:
      - "8545"
      - "8546"
    environment:
      VIRTUAL_HOST: "test1.example.com:8546,test2.example.com:8545"
      LETSENCRYPT_HOST: "test1.example.com,test2.example.com"

networks:
  default:
    external:
      name: webproxy

And nginx template parse it like that

# test2.example.com:8545
upstream test2.example.com:8545 {
        ## Can be connect with "webproxy" network
    server 172.19.0.8 down;
}
server {
  server_name test2.example.com:8545;
  listen 80 ;
  access_log /var/log/nginx/access.log vhost;
  include /etc/nginx/vhost.d/default;
  location / {
    proxy_pass http://test2.example.com:8545;
  }
}
# test1.example.com:8546
upstream test1.example.com:8546 {
        ## Can be connect with "webproxy" network
    server 172.19.0.8 down;
}
server {
  server_name test1.example.com:8546;
  listen 80 ;
  access_log /var/log/nginx/access.log vhost;
  include /etc/nginx/vhost.d/default;
  location / {
    proxy_pass http://test1.example.com:8546;
  }
}

Servername has a port and this is a trouble. Also I dont sure that upstream has a right name.
Can you please provide the correct nginx template to work with more than one exposed port.
Thank you

@hookenz
Copy link

hookenz commented Feb 13, 2018

I'm having this problem too. I have EXPOSE with more than one port listed in the Dockerfile. But only one -p given on the command line. The upstream was missing the port. If I EXPOSE only a single port it works.

I would think the correct functionality should be one upstream DNS name but with multiple server entries that include each port number exposed by -p.

@UnrealKazu
Copy link

There is no support for multiple hosts with different ports as of now. This is a feature request that has existed for quite some time now, as you can see in #59

@frederikbosch
Copy link

See PR #1157.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature-request Issue requesting a new feature scope/multiport Issue or PR related to multi port proxying
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants