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

Same docker-compose.yml performs different nginx port binding #1148

Closed
toby1991 opened this issue Feb 10, 2017 · 5 comments
Closed

Same docker-compose.yml performs different nginx port binding #1148

toby1991 opened this issue Feb 10, 2017 · 5 comments

Comments

@toby1991
Copy link

What version of Traefik are you using (traefik version)?

1.1.2 and 1.2.0-rc1 [docker]

What is your environment & configuration (arguments, toml...)?

version: "2"

networks:
  loadbalance:
    driver: bridge

services:
  # traefik
  traefik:
    image: traefik:1.2.0-rc1
    networks:
      - loadbalance
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /dev/null:/traefik.toml
    command: --web --docker --docker.domain=test.local --logLevel=DEBUG
    restart: always

  ######################################################################################

  # web server
  nginx:
    image: nginx:latest
    networks:
      - loadbalance
    ports:
      - "80"
    volumes:
      # app
      - ./app/src:/usr/share/nginx/html
      # nginx configs
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx/conf.d/:/etc/nginx/conf.d/:ro

      - ./nginx/fastcgi.conf:/etc/nginx/fastcgi.conf:ro
      - ./nginx/pathinfo.conf:/etc/nginx/pathinfo.conf:ro
      - ./nginx/laravel.conf:/etc/nginx/laravel.conf:ro
      # certificates
      - ./nginx/ca/server.crt/:/etc/nginx/server.crt:ro
      - ./nginx/ca/server.key/:/etc/nginx/server.key:ro
      # logs
      - ./nginx/logs:/var/log/nginx/log
    labels:
      - "traefik.backend=nginx"
      - "traefik.frontend.rule=HostRegexp:test.local,m.test.local"
    restart: always

What did you do?

docker-compose up -d

What did you expect to see?

nginx port 80 listening

What did you see instead?

same docker-compose.yml , after

docker-compose up -d 
docker-compose down
docker-compose up -d

performs different.


Some times it listens nginx 80 port

image

listens port 80 logs

Creating network "docker_loadbalance" with driver "bridge"
Creating docker_traefik_1
Creating docker_nginx_1
Attaching to docker_traefik_1, docker_nginx_1
traefik_1  | time="2017-02-10T08:27:23Z" level=info msg="Traefik version v1.2.0-rc1 built on 2017-02-06_08:45:49PM"
traefik_1  | time="2017-02-10T08:27:23Z" level=info msg="Using TOML configuration file //traefik.toml"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Global configuration loaded {\"GraceTimeOut\":10,\"Debug\":false,\"CheckNewVersion\":true,\"AccessLogsFile\":\"\",\"TraefikLogsFile\":\"\",\"LogLevel\":\"DEBUG\",\"EntryPoints\":{\"http\":{\"Network\":\"\",\"Address\":\":80\",\"TLS\":null,\"Redirect\":null,\"Auth\":null,\"Compress\":false}},\"Cluster\":null,\"Constraints\":[],\"ACME\":null,\"DefaultEntryPoints\":[\"http\"],\"ProvidersThrottleDuration\":2000000000,\"MaxIdleConnsPerHost\":200,\"InsecureSkipVerify\":false,\"Retry\":null,\"Docker\":{\"Watch\":true,\"Filename\":\"\",\"Constraints\":null,\"Endpoint\":\"unix:///var/run/docker.sock\",\"Domain\":\"test.local\",\"TLS\":null,\"ExposedByDefault\":true,\"UseBindPortIP\":false,\"SwarmMode\":false},\"File\":null,\"Web\":{\"Address\":\":8080\",\"CertFile\":\"\",\"KeyFile\":\"\",\"ReadOnly\":false,\"Statistics\":null,\"Metrics\":null,\"Auth\":null},\"Marathon\":null,\"Consul\":null,\"ConsulCatalog\":null,\"Etcd\":null,\"Zookeeper\":null,\"Boltdb\":null,\"Kubernetes\":null,\"Mesos\":null,\"Eureka\":null,\"ECS\":null,\"Rancher\":null}"
traefik_1  | time="2017-02-10T08:27:23Z" level=info msg="Preparing server http &{Network: Address::80 TLS:<nil> Redirect:<nil> Auth:<nil> Compress:false}"
traefik_1  | time="2017-02-10T08:27:23Z" level=info msg="Starting provider *provider.Docker {\"Watch\":true,\"Filename\":\"\",\"Constraints\":null,\"Endpoint\":\"unix:///var/run/docker.sock\",\"Domain\":\"test.local\",\"TLS\":null,\"ExposedByDefault\":true,\"UseBindPortIP\":false,\"SwarmMode\":false}"
traefik_1  | time="2017-02-10T08:27:23Z" level=info msg="Starting provider *main.WebProvider {\"Address\":\":8080\",\"CertFile\":\"\",\"KeyFile\":\"\",\"ReadOnly\":false,\"Statistics\":null,\"Metrics\":null,\"Auth\":null}"
traefik_1  | time="2017-02-10T08:27:23Z" level=info msg=0s
traefik_1  | time="2017-02-10T08:27:23Z" level=info msg="Starting server on :80"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Docker connection established with docker 1.13.0 (API 1.25)"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Load balancer method '<nil>' for backend backend-docker-traefik-1: Invalid method, using default. Using default wrr."
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Load balancer method '<nil>' for backend backend-nginx: Invalid method, using default. Using default wrr."
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Configuration received from provider docker: {\"backends\":{\"backend-docker-traefik-1\":{\"servers\":{\"server-docker_traefik_1\":{\"url\":\"http://172.18.0.2:443\",\"weight\":0}},\"loadBalancer\":{\"method\":\"wrr\"}},\"backend-nginx\":{\"servers\":{\"server-docker_nginx_1\":{\"url\":\"http://172.18.0.3:80\",\"weight\":0}},\"loadBalancer\":{\"method\":\"wrr\"}}},\"frontends\":{\"frontend-Host-docker-traefik-1-test-local\":{\"entryPoints\":[\"http\"],\"backend\":\"backend-docker-traefik-1\",\"routes\":{\"route-frontend-Host-docker-traefik-1-test-local\":{\"rule\":\"Host:docker-traefik-1.test.local\"}},\"passHostHeader\":true,\"priority\":0},\"frontend-HostRegexp-test-local-m-test-local\":{\"entryPoints\":[\"http\"],\"backend\":\"backend-nginx\",\"routes\":{\"route-frontend-HostRegexp-test-local-m-test-local\":{\"rule\":\"HostRegexp:test.local,m.test.local\"}},\"passHostHeader\":true,\"priority\":0}}}"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Last docker config received more than 2s, OK"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Creating frontend frontend-Host-docker-traefik-1-test-local"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Wiring frontend frontend-Host-docker-traefik-1-test-local to entryPoint http"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Creating route route-frontend-Host-docker-traefik-1-test-local Host:docker-traefik-1.test.local"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Creating backend backend-docker-traefik-1"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Creating load-balancer wrr"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Creating server server-docker_traefik_1 at http://172.18.0.2:443 with weight 0"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Creating frontend frontend-HostRegexp-test-local-m-test-local"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Wiring frontend frontend-HostRegexp-test-local-m-test-local to entryPoint http"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Creating route route-frontend-HostRegexp-test-local-m-test-local HostRegexp:test.local,m.test.local"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Creating backend backend-nginx"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Creating load-balancer wrr"
traefik_1  | time="2017-02-10T08:27:23Z" level=debug msg="Creating server server-docker_nginx_1 at http://172.18.0.3:80 with weight 0"
traefik_1  | time="2017-02-10T08:27:23Z" level=info msg="Server configuration reloaded on :80"

some times it listens nginx 443 port which will cause a 502 bad gateway response.

image

listens port 443 logs

Creating network "docker_loadbalance" with driver "bridge"
Creating docker_traefik_1
Creating docker_nginx_1
Attaching to docker_traefik_1, docker_nginx_1
traefik_1  | time="2017-02-10T08:23:34Z" level=info msg="Traefik version v1.2.0-rc1 built on 2017-02-06_08:45:49PM"
traefik_1  | time="2017-02-10T08:23:34Z" level=info msg="Using TOML configuration file //traefik.toml"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Global configuration loaded {\"GraceTimeOut\":10,\"Debug\":false,\"CheckNewVersion\":true,\"AccessLogsFile\":\"\",\"TraefikLogsFile\":\"\",\"LogLevel\":\"DEBUG\",\"EntryPoints\":{\"http\":{\"Network\":\"\",\"Address\":\":80\",\"TLS\":null,\"Redirect\":null,\"Auth\":null,\"Compress\":false}},\"Cluster\":null,\"Constraints\":[],\"ACME\":null,\"DefaultEntryPoints\":[\"http\"],\"ProvidersThrottleDuration\":2000000000,\"MaxIdleConnsPerHost\":200,\"InsecureSkipVerify\":false,\"Retry\":null,\"Docker\":{\"Watch\":true,\"Filename\":\"\",\"Constraints\":null,\"Endpoint\":\"unix:///var/run/docker.sock\",\"Domain\":\"test.local\",\"TLS\":null,\"ExposedByDefault\":true,\"UseBindPortIP\":false,\"SwarmMode\":false},\"File\":null,\"Web\":{\"Address\":\":8080\",\"CertFile\":\"\",\"KeyFile\":\"\",\"ReadOnly\":false,\"Statistics\":null,\"Metrics\":null,\"Auth\":null},\"Marathon\":null,\"Consul\":null,\"ConsulCatalog\":null,\"Etcd\":null,\"Zookeeper\":null,\"Boltdb\":null,\"Kubernetes\":null,\"Mesos\":null,\"Eureka\":null,\"ECS\":null,\"Rancher\":null}"
traefik_1  | time="2017-02-10T08:23:34Z" level=info msg="Preparing server http &{Network: Address::80 TLS:<nil> Redirect:<nil> Auth:<nil> Compress:false}"
traefik_1  | time="2017-02-10T08:23:34Z" level=info msg="Starting provider *provider.Docker {\"Watch\":true,\"Filename\":\"\",\"Constraints\":null,\"Endpoint\":\"unix:///var/run/docker.sock\",\"Domain\":\"test.local\",\"TLS\":null,\"ExposedByDefault\":true,\"UseBindPortIP\":false,\"SwarmMode\":false}"
traefik_1  | time="2017-02-10T08:23:34Z" level=info msg="Starting provider *main.WebProvider {\"Address\":\":8080\",\"CertFile\":\"\",\"KeyFile\":\"\",\"ReadOnly\":false,\"Statistics\":null,\"Metrics\":null,\"Auth\":null}"
traefik_1  | time="2017-02-10T08:23:34Z" level=info msg=0s
traefik_1  | time="2017-02-10T08:23:34Z" level=info msg="Starting server on :80"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Docker connection established with docker 1.13.0 (API 1.25)"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Load balancer method '<nil>' for backend backend-docker-traefik-1: Invalid method, using default. Using default wrr."
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Load balancer method '<nil>' for backend backend-nginx: Invalid method, using default. Using default wrr."
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Configuration received from provider docker: {\"backends\":{\"backend-docker-traefik-1\":{\"servers\":{\"server-docker_traefik_1\":{\"url\":\"http://172.18.0.2:443\",\"weight\":0}},\"loadBalancer\":{\"method\":\"wrr\"}},\"backend-nginx\":{\"servers\":{\"server-docker_nginx_1\":{\"url\":\"http://172.18.0.3:443\",\"weight\":0}},\"loadBalancer\":{\"method\":\"wrr\"}}},\"frontends\":{\"frontend-Host-docker-traefik-1-test-local\":{\"entryPoints\":[\"http\"],\"backend\":\"backend-docker-traefik-1\",\"routes\":{\"route-frontend-Host-docker-traefik-1-test-local\":{\"rule\":\"Host:docker-traefik-1.test.local\"}},\"passHostHeader\":true,\"priority\":0},\"frontend-HostRegexp-test-local-m-test-local\":{\"entryPoints\":[\"http\"],\"backend\":\"backend-nginx\",\"routes\":{\"route-frontend-HostRegexp-test-local-m-test-local\":{\"rule\":\"HostRegexp:test.local,m.test.local\"}},\"passHostHeader\":true,\"priority\":0}}}"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Last docker config received more than 2s, OK"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Creating frontend frontend-Host-docker-traefik-1-test-local"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Wiring frontend frontend-Host-docker-traefik-1-test-local to entryPoint http"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Creating route route-frontend-Host-docker-traefik-1-test-local Host:docker-traefik-1.test.local"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Creating backend backend-docker-traefik-1"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Creating load-balancer wrr"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Creating server server-docker_traefik_1 at http://172.18.0.2:443 with weight 0"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Creating frontend frontend-HostRegexp-test-local-m-test-local"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Wiring frontend frontend-HostRegexp-test-local-m-test-local to entryPoint http"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Creating route route-frontend-HostRegexp-test-local-m-test-local HostRegexp:test.local,m.test.local"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Creating backend backend-nginx"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Creating load-balancer wrr"
traefik_1  | time="2017-02-10T08:23:34Z" level=debug msg="Creating server server-docker_nginx_1 at http://172.18.0.3:443 with weight 0"
traefik_1  | time="2017-02-10T08:23:34Z" level=info msg="Server configuration reloaded on :80"
@toby1991
Copy link
Author

here are the log diff between port 80 and port 443

image

I didn't change anything in the docker-compose.yml

@dtomcej
Copy link
Contributor

dtomcej commented Feb 10, 2017

Hey toby, can you please add:

-label traefik.port=80 to your nginx config and retry?

@toby1991
Copy link
Author

@dtomcej THKS . But I've tried all the labels about port in the docker-compose.yml , still nothing helps ..

@errm
Copy link
Contributor

errm commented Feb 22, 2017

@toby1991 Could you confirm if you did indeed try adding -label traefik.port=80 to the labels on the nginx container?

@toby1991
Copy link
Author

@errm I got it. If I don't add traefik.port=80 to the label option, traefik would use port 80 or 443 randomly.

One more question, If my backend-nginx has 2 sites, and one is using protocol http, another one is using protocol https, how could I set the label at my backend-nginx ?

@ldez ldez closed this as completed in #1523 May 3, 2017
@traefik traefik locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants