I set in jenkins two variables
"VIRTUAL_HOST=jenkins.xxx.com"
"VIRTUAL_PORT=8020"
but in nginx-proxy console I get:
nginx.1 | jenkins.xxx.info 10.0.3.1 - - [26/Jan/2017:14:22:10 +0000] "GET / HTTP/1.1" 502 166 "-"
"Mozilla/5.0 (Windows NT
10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0"
nginx.1 | 2017/01/26 14:22:10 [error] 39#39: *24 no live upstreams while connecting to upstream, client: 10.0.3.1, server: jen
kins.xxx.info, request: "GET / HTTP/1.1", upstream: "http://7388ea39588cd39638dc61b60d26fe329b4cdc1d/", host: "jenkins.xxx.
info"
Why is client 10.0.3.1?
My config:
docker exec 91d3279be4b6 cat /etc/nginx/conf.d/default.conf
cat: /etc/nginx/conf.d/default.conf.: No such file or directory
[/] # docker exec 91d3279be4b6 cat /etc/nginx/conf.d/default.conf
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
default $http_x_forwarded_proto;
'' $scheme;
}
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port {
default $http_x_forwarded_port;
'' $server_port;
}
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
default upgrade;
'' close;
}
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl {
default off;
https on;
}
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
log_format vhost '$host $remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
access_log off;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
server {
server_name _; # This is just an invalid value which will never trigger on a real hostname.
listen 80;
access_log /var/log/nginx/access.log vhost;
return 503;
}
# jenkins.xxx.info
upstream 7388ea39588cd39638dc61b60d26fe329b4cdc1d {
## Can be connect with "bridge" network
# jenkins-1
server 10.0.3.6 down;
}
server {
server_name jenkins.xxx.info;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
location / {
proxy_pass http://7388ea39588cd39638dc61b60d26fe329b4cdc1d;
}
}
I was getting the same error when running a simple nodejs service behind the nginx-proxy. It turns out I forgot to EXPOSE my port in the Dockerfile. After fixing that the proxy worked as expected. Not sure if this information helps you, but I figured it may be worth mentioning.
Hi
docker ps:
3763e44da4d4 jenkins:2.19.1 "/bin/tini -- /usr/lo" 5 minutes ago Up 5 minutes 0.0.0.0:8020->8080/tcp, 0.0.0.0:50001->50000/tcp jenkins-1
I think port 8020 is expose correctly?
NOPE.
you used -p to PUBLISH port 8020:8080
you need to --expose 8020
I am getting this same error, just want to check I have setup everything I need, I setup nginx-proxy using docker compose and ran it with docker-compose up, I have added network and VIRTUAL_HOST, VIRTUAL_PORT to my docker nginx containers docker-compose file and brought that up. Getting the above error, do i need to do anything else, do I need to muck with my original nginx server configs, love to get this working! thanks
Most helpful comment
I was getting the same error when running a simple nodejs service behind the nginx-proxy. It turns out I forgot to
EXPOSEmy port in the Dockerfile. After fixing that the proxy worked as expected. Not sure if this information helps you, but I figured it may be worth mentioning.