This thread has been dormant for a little while, but Iām running into the same problem.
Iām using jenkinsci/blueocean with nginx, letsencrypt-nginx-proxy-companion and jwilder/nginx-proxy to docker-compose up a Jenkins server with https provided by letsencrypt. Everything seems to be starting up fine, and the jwilder/nginx-proxy container recceives the request and correctly attempts to route it to the nginx container but gets connection refused on port 80:
nginx-proxy_1 | nginx.1 | 2019/06/16 19:43:37 [error] 90#90: *1 connect() failed (111: Connection refused) while connecting to upstream, client: <my IP>, server: jenkins.<my domain>.com, request: "GET / HTTP/2.0", upstream: "http://172.18.0.4:80/", host: "jenkins.<my domain>.com"
nginx-proxy_1 | nginx.1 | jenkins.<my domain>.com <my IP> - - [16/Jun/2019:19:43:37 +0000] "GET / HTTP/2.0" 502 575 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
nginx-proxy_1 | nginx.1 | 2019/06/16 19:43:37 [error] 90#90: *1 connect() failed (111: Connection refused) while connecting to upstream, client: <my IP>, server: jenkins.<my domain>.com, request: "GET /favicon.ico HTTP/2.0", upstream: "http://172.18.0.4:80/favicon.ico", host: "jenkins.<my domain>.com", referrer: "https://jenkins.<my domain>.com/"
nginx-proxy_1 | nginx.1 | jenkins.<my domain>.com <my IP> - - [16/Jun/2019:19:43:37 +0000] "GET /favicon.ico HTTP/2.0" 502 575 "https://jenkins.<my domain>.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
I have confirmed that all containers are on the same network, and I added a busybox-curl container to the network to verify that I can ping the nginx container from inside the network. But if I try curl the nginx container by name or by container-ip-address I get the same connection refused on port 80 that the proxy container is getting:
/ # ping 172.18.0.4
PING 172.18.0.4 (172.18.0.5): 56 data bytes
64 bytes from 172.18.0.4: seq=0 ttl=64 time=0.165 ms
64 bytes from 172.18.0.4: seq=1 ttl=64 time=0.092 ms
64 bytes from 172.18.0.4: seq=2 ttl=64 time=0.120 ms
^C
--- 172.18.0.4 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.092/0.125/0.165 ms
/ # curl http://jenkins_nginx_1
curl: (7) Failed to connect to jenkins_nginx_1 port 80: Connection refused
/ # curl http://172.18.0.4
curl: (7) Failed to connect to 172.18.0.4 port 80: Connection refused
/ # exit
Sincerely hoping a Docker genius can help me out
PS, here is my docker-compose.yml:
version: '2'
services:
jenkins:
image: jenkinsci/blueocean:1.17.0
volumes:
- 'jenkins_data:/var/jenkins_home'
- '/var/run/docker.sock:/var/run/docker.sock'
ports:
- '8080:8080'
- '8443:8443'
environment:
- 'JENKINS_OPTS=--httpPort=8080 --httpsPort=8443'
nginx:
image: nginx
links:
- jenkins
volumes:
- "./etc/nginx/conf.d/:/etc/nginx/conf.d/"
expose:
- "80"
environment:
VIRTUAL_HOST: jenkins.<my domain>.com
LETSENCRYPT_HOST: jenkins.<my domain>.com
LETSENCRYPT_EMAIL: info@<my domain>.com
nginx-proxy:
image: jwilder/nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- "./nginx/vhost.d:/etc/nginx/vhost.d"
- "./nginx/html:/usr/share/nginx/html"
- "./nginx/certs:/etc/nginx/certs"
- "/var/run/docker.sock:/tmp/docker.sock:ro"
letsencrypt-nginx-proxy-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
volumes_from:
- "nginx-proxy"
volumes:
jenkins_data:
driver: local