I get 502 bad gateway when connecting to my NodeBB installation using my domain
NodeBB is running on default port (4567)
My nginx seems to be configured properly (when connecting using the IP): http://puu.sh/mLI7U/0e03691d4c.png
My nodebb seems to be configured properly (when connecting using the IP):
http://puu.sh/mLI95/5fdafcaed9.png
My A record directing the IP to my VPS is configured properly.
Here is my etc/nginx/conf.d/example.com.conf
server {
listen 80;
server_name sporklounge.com;
location / {
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://127.0.0.1:4567/;
proxy_redirect off;
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
My NodeBB config.json
{
"url": "http://localhost:4567",
"secret": "25d0d6a2-0444-49dc-af0c-bd693f5829d8",
"database": "redis",
"redis": {
"host": "127.0.0.1",
"port": "6379",
"password": "",
"database": "0"
}
}
Here is my var/log/nginx/error.log
2016/01/27 12:04:42 [error] 22026#0: *4062 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 50.186.224.26, server: sporklounge.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:80/favicon.ico", host: "sporklounge.com", referrer: "http://sporklounge.com/"
2016/01/27 12:21:06 [crit] 974#0: *1 connect() to 127.0.0.1:4567 failed (13: Permission denied) while connecting to upstream, client: 50.186.224.26, server: sporklounge.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:4567/", host: "sporklounge.com"
2016/01/27 12:21:07 [crit] 974#0: *1 connect() to 127.0.0.1:4567 failed (13: Permission denied) while connecting to upstream, client: 50.186.224.26, server: sporklounge.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:4567/favicon.ico", host: "sporklounge.com", referrer: "http://sporklounge.com/"
All help is greatly appreciated and I will answer all questions that i can to help get a solution, thank you!
The one thing I see is that according to the docs, your url config value should be the full web-accessible address that points to your NodeBB. That would be sporklounge.com, not the current value.
It could also be that the backend is just sometimes responding slowly. Try very high values of this value in Nginx to see if the backend eventually responds:
# For testing, allow very long response times.
proxy_read_timeout 5m;
Also, use netstat to confirm the backend is running on port 4567:
sudo netstat -nlp | grep ':4567'
Wait, the answer may right in your logs, which give you the reason for the connection failure:
(13: Permission denied) while connecting to upstream
See the related question:
(13: Permission denied) while connecting to upstream:[nginx]
Related
I am trying to proxy_pass requests using nginx to a public fqdn.
The server has LB configured only to respond to requests when accessed using fqdn and get an ssl hand shake error when accessed using IP.
My issue is that the nginx is implicitly converting the fqdn to set of IPs and trying them one by one and failing.
Is there a way have nginx proxy_pass without converting the fqdn to IP and route the request to upstream at fqdn?
location /public/api {
proxy_pass https://public.server.com/api;
proxy_set_header Host $host;
}
2022/04/24 23:10:20 [error] 912419#912419: *5 peer closed connection in SSL handshake (104: Connection reset by peer) while SSL handshaking to upstream, client: xxxxxxxx, server: _, request: "POST /<api> HTTP/1.1", upstream: "https://<ip1>:443/<api>", host: "<ip>"
2022/04/24 23:10:20 [error] 912419#912419: *5 peer closed connection in SSL handshake (104: Connection reset by peer) while SSL handshaking to upstream, client: xxxxxxxx, server: _, request: "POST /<api> HTTP/1.1", upstream: "https://<ip2>43/<api>", host: "<ip>"
2022/04/24 23:10:20 [error] 912419#912419: *5 peer closed connection in SSL handshake (104: Connection reset by peer) while SSL handshaking to upstream, client: xxxxxxxx, server: _, request: "POST /<api> HTTP/1.1", upstream: "https://<ip3>:443/<api>", host: "<ip>"
Add client certificate and private key to verify nginx and each back-end server. Using proxy_ssl_certificate and proxy_ssl_certificate_key instruction:
location /public/api {
proxy_pass https://public.server.com/api;
proxy_set_header Host $host;
proxy_ssl_certificate /etc/nginx/client.pem;
proxy_ssl_certificate_key /etc/nginx/client.key
}
I am trying to access URL from the browser
http://example.com/validateResetPassword/?access_token=8E27UWYuamdf
my Nginx location mapping is:
location ~* /validateResetPassword {
proxy_pass http://localhost:8085/$request_uri;
proxy_set_header Host $host;
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 $scheme;
}
so whenever request comes like from browser
http://example.com/validateResetPassword/?access_token=8E27UWYuam
it should redirect to my spring boot application on port 8085.
I also tried after removing ~* but nothing is working.
also, I can see below error:
2019/11/25 13:19:29 [info] 13780#13780: *37 client closed connection while waiting for request, client: 10.68.104.173, server: 10.121.42.22:80
2019/11/25 13:19:29 [error] 13783#13783: *39 no resolver defined to resolve localhost, client: 10.68.104.173, server: mydoamin.com, request: "GET /validateResetPassword/dsfsdfsd HTTP/1.1", host: "example.com"
2019/11/25 13:19:30 [error] 13783#13783: *39 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 10.68.104.173, server: uc1f-bioinfocloud-algae-dev, request: "GET /favicon.ico HTTP/1.1", host: "uc1f-bioinfocloud-algae-dev", referrer: "http://example.com/validateResetPassword/dsfsdfsd"
This sounds quite critical to me:
*39 no resolver defined to resolve localhost
Did you try changing it to 127.0.0.1?
edit:
it should redirect to my spring boot application on port 8085.
If you use proxy*, you are not about to redirect but doing a subrequest to another host...
i am having a issue trying to authenticate my account with github plugin and a reverse-proxy which is nginx, this is my configuration
Gerrit version: 2.14.8
$ cat /etc/nginx/sites-available/my_config_file
server {
listen 443;
server_name my_server_hostname;
ssl on;
ssl_certificate conf.d/certificate.crt;
ssl_certificate_key conf.d/certificate.key;
location ^~ / {
proxy_pass http://127.0.0.1:8081;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
$ cat /var/log/nginx/error.log
018/08/15 08:49:47 [error] 3247#3247: *1 SSL_do_handshake() failed (SSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol) while SSL handshaking to upstream, client: IP_ADDRESS, server: my_server_hostname, request: "GET / HTTP/1.1", upstream: "https://127.0.0.1:8081/", host: "my_server_hostname"
Gerrit log does not shows any error
I think that this is a very simple issue but i can not figure out how to fix it, please help me on this.
Thanks
I'm running a couple of sails.js backend instances behind an nginx proxy with sticky sessions.
I keep seeing a lot of messages in my nginx error.log regarding sails.js /socket.io/ URLs timing out:
2016/01/04 20:55:15 [error] 12106#12106: *402088 upstream timed out (110: Connection timed out) while reading response header from upstream, client: x.x.x.x, server: example.com, request: "GET /socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=polling&t=1451930055065-4&sid=jvekCYDAcFfu0PLdAAL6 HTTP/1.1", upstream: "http://127.0.0.1:3001/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=polling&t=1451930055065-4&sid=jvekCYDAcFfu0PLdAAL6", host: "example.com", referrer: "https://example.com/languageExchange/chat/63934"
2016/01/04 20:55:17 [error] 12105#12105: *402482 upstream prematurely closed connection while reading response header from upstream, client: y.y.y.y, server: example.com, request: "GET /socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=QnAe1jiKEHgj-zlKAAKu HTTP/1.1", upstream: "http://127.0.0.1:3001/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=QnAe1jiKEHgj-zlKAAKu", host: "example.com"
2016/01/04 22:32:33 [error] 12107#12107: *437054 no live upstreams while connecting to upstream, client: z.z.z.z, server: example.com, request: "GET /socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=8G2TfOsNOJMYHZOjAAD3 HTTP/1.1", upstream: "http://sails/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=8G2TfOsNOJMYHZOjAAD3", host: "example.com"
It doesn't happen for every client, but the number of such messages is significant. And sails.js does not show any relevant errors.
How should I investigate the nature of these issues?
Here's what I've tried so far (and it didn't help):
Upgrade socket.io client to the latest version so far (1.3.7)
Explicitly turn off caching for /socket.io/ requests in nginx
Here's the relevant config files:
sails sockets.js:
adapter: 'socket.io-redis'
nginx:
location ^~ /socket.io/ {
proxy_pass http://sails;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $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_no_cache true;
proxy_cache_bypass true;
proxy_redirect off;
proxy_intercept_errors off;
}
Im running mu Nginx as revers proxy to serv content from remote url , it was working fine for while , when i moved it to another host , i start getting the following erros
i tested internet though new host all is fine evern nginx serv from root location without issue but when i request a location that serv as revers proxt am getting
8583#0: *2 upstream timed out (110: Connection timed out) while
connecting to upstream, client: 10.64.159.12, server: xxxxx.com,
request: "GET /web/rest/v1/story/656903.json HTTP/1.1", upstream:
"http://requestedurl.com:80/web/rest/v1/story/656903.json", host: "myurl.com"
Location Config :
location /data {
sub_filter 'http' 'https';
sub_filter_once off;
sub_filter_types application/json;
proxy_read_timeout 300;
proxy_pass http://url here ;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header Accept-Encoding "";
Any advise