Problem
I am attempting to achieve a docker+nginx setup with upstart and a node.js app on one ubuntu server.
I have the node.js app running and I am able to connect to it directly. And the nginx default server worked for me. However, I am encountering 502 bad gateways when trying to link the two. I am wondering if it may be due to my ipv6 node address (not intentional, but shown in netstat below).
Sorry if this is a noob question/config issue. I am new to nginx and ubuntu. I have combed several helpful articles and found neat linux commands, but none of the solutions have worked for me so far.
cat /proc/version:
Linux version 4.4.0-72-generic (buildd@lcy01-24) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) ) #93~14.04.1-Ubuntu SMP Fri Mar 31 15:05:15 UTC 2017
netstat -tpln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:21 0.0.0.0:* LISTEN 599/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1305/sshd
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 24199/mongod
tcp6 0 0 :::22 :::* LISTEN 1305/sshd
tcp6 0 0 :::8443 :::* LISTEN 11608/.node.bin
tcp6 0 0 :::80 :::* LISTEN 13646/docker-proxy
nginx.conf
# the IP(s) on which your node server is running.
upstream app_yourdomain {
server [::1]:8443;
keepalive 8;
}
# the nginx server instance
server {
listen 80;
server_name [::1];
rewrite_log on;
error_log /var/log/nginx/localhost.error_log notice;
# pass the request to the node.js server with the correct headers
# and much more can be added, see nginx config options
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app_yourdomain;
proxy_redirect off;
}
}
Error.log
Using server http:// 127.0.0.1:8443 in app_yourdomain
2017/05/02 21:50:22 [error] 5#5: *1 connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XX, server: http://XXX.XX.XXX.XXX, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8443/", host: "XXX.XX.XXX.XXX"
2017/05/02 21:50:22 [warn] 5#5: *1 upstream server temporarily disabled while connecting to upstream, client: XXX.XXX.XXX.XX, server: http://XXX.XX.XXX.XXX, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8443/", host: "XXX.XX.XXX.XXX"
Using server [::1]:8443 in app_yourdomain
2017/05/02 22:13:20 [crit] 5#5: *1 connect() to [::1]:8443 failed (99: Cannot assign requested address) while connecting to upstream, client: XXX.XXX.XXX.XX, server: localhost, request: "GET / HTTP/1.1", upstream: "http://[::1]:8443/", host: "XXX.XX.XXX.XXX"
via Justin Reigel
No comments:
Post a Comment