I setup project on the aws ec2. I am able to build the project but not able to access it. Here is the error from log
[error] 14462#14462: *23 connect() failed (111: Connection refused) while connecting to upstream, client: xx.243.37.87, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://xxx.31.45.195:3000/favicon.ico", host: "13.xxx.109.248", referrer: "http://13.xxx.109.248/"
server {
listen 80;
root /var/www/react-web/build;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection ‘upgrade’;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Can anybody help me to fix the issue?
Thanks
Related
I have set up my node.js server using elastic beanstalk. Recently I have seen that my server health is degrading to sever from ok state and I keep getting emails for that.
While checking the logs in the error. logs of Nginx I found out that most of the errors are occurring because of
2022/04/23 18:34:14 [error] 3620#0: *14 upstream prematurely closed connection while reading response header from upstream, client: 172.31.54.200, server: , request: "POST /parse/functions/processCloverRequest HTTP/1.1", upstream: "http://155.0.0.1:8081/parse/functions/processCloverRequest", host: "server-i9cck-env.us-east-1.elasticbeanstalk.com"
I have also handled each error in the application and increased the read and connect timeout of Nginx.
location / {
proxy_pass http://nodejs;
proxy_set_header Connection "";
proxy_http_version 1.1;
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_read_timeout 300s;
proxy_connect_timeout 75s;
}
But still I am getting the emails and the health of my instances degrades. Is there a way to resolve this issue?
We have developed a testing application in Twilio Sandbox and it is running fine in Heroku server. But when we are trying to put it in Linux (centos 8.1.1911) server, getting 404 error.
conf file in Linux server:
location /myapp/ {
proxy_pass http://13.71.23.139:3020/;
proxy_ssl_server_name on;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
error:
*212 connect() failed (111: Connection refused) while connecting to upstream
Any suggestions?
On landing.example.com:10000 have I a webserver that works fine, which is a Docker container that exposes port 10000. Its IP is 172.17.0.2.
What I would like is having a nginx reverse proxy on port 80, and send the visitor to different Docker containers depending on the URL they visit.
server {
listen 80;
server_name landing.example.com;
location / {
proxy_pass http://172.17.0.2:10000/;
}
access_log /landing-access.log;
error_log /landing-error.log info;
}
When I do this, I get 502 Bad Gateway and the log says
2016/04/14 16:58:16 [error] 413#413: *84 connect()
failed (111: Connection refused) while connecting to upstream, client:
xxx.xxx.xxx.xxx, server: landing.example.com, request: "GET / HTTP/1.1",
upstream: "http://172.17.0.2:10000/", host: "landing.example.com"
try this:
upstream my_server {
server 172.17.0.2:10000;
}
server {
listen 80;
server_name landing.example.com;
location / {
proxy_pass http://my_server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
proxy_redirect http:// $scheme://;
}
}
Here you define the upstream server (your server by IP or hostname)
and make sure to forward the headers too so the server answering knowns who to answer to.
Have a Frontend server which accesses a backend api all written in node.js.
Currently have Nginx with Phusion Passenger configured to launch the node app
Everything has been running fine when all environments (dev.qa.prod) experienced this similar issue which crashed our Frontend servers. Restarting Nginx allowed the application to work.
The Errors look like this
[error] 25833#0: *14050 upstream prematurely closed connection while reading response header from upstream, client: 10.0.0.183, server: 54.148.10.11, request: "POST /api/course/54e113e8d98e579c1a790bbd/step/54e113e8d98e579c1a790bbe HTTP/1.1", upstream: "https://54.201.58.163:443/api/course/54e113e8d98e579c1a790bbd/step/54e113e8d98e579c1a790bbe", host: "dev.****.net", referrer: "https://dev.***.net/08f35b9a752554df591279a88babad96fd7e88021084d0396ef7bda16798eaa5743bfc4880015294dd3199482dd9fc564bbf6a681b6881eb5d91b369059a1643"
Nginx Configuration under sites-available/default:
server {
server_name 10.0.0.134;
listen 80;
root /home/ubuntu/web/portal;
passenger_enabled on;
passenger_set_cgi_param _PASSENGER_NODE_CONTROL_SERVER 1;
location /api {
access_log off;
proxy_pass https://dev-api.***.net;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 300;
}}
Quick breakdown -
Dev environment works properly. SSL Cert on local server, nginx configured for proxy pass on 443 traffic.
location / {
proxy_pass http://localhost:3000;
proxy_set_header X-Real-IP $remote_addr;
#proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
for some reason, version 1.1 never works (always tosses an error)
Again, Dev environment works properly.
Production environment is giving me the following error:
WebSocket connection to 'wss://website.com/sockjs/421/fin4cg38/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400
I use a load balancer which has the SSL cert on it and we enforce SSL through our application.
Now, I checked the configuration of NGINX and I have it as follows:
server {
listen 80;
server_name www.website.com;
error_log /var/log/nginx/sites-error.log;
return 301 https://website.com$request_uri;
}
server {
listen 80 default_server;
server_name _;
location / {
proxy_pass http://localhost:3000;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
The way its set up is anything on 80 goes to 443, etc etc.
If I uncomment the proxy_set_headers, our sign up breaks and the chrome console doesn't show any errors.
error log has this:
2014/07/13 18:15:16 [error] 16175#0: *93 connect() failed (111: Connection refused) while connecting to upstream, client: 10.189.245.5, server: _, request: "POST /sockjs/421/wq2dqb2w/xhr_send HTTP/1.1", upstream: "http://[::1]:3000/sockjs/421/wq2dqb2w/xhr_send", host: "website.com", referrer: "https://website.com/signIn"
2014/07/13 18:15:42 [error] 16487#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 10.189.245.5, server: _, request: "GET /sockjs/120/95m6dozn/websocket HTTP/1.1", upstream: "http://[::1]:3000/sockjs/120/95m6dozn/websocket", host: "website.com"
2014/07/13 18:16:12 [error] 16487#0: *12 connect() failed (111: Connection refused) while connecting to upstream, client: 10.189.245.5, server: _, request: "GET /f1be3f98162c975fdc9524a0a222f9a02cc6dcde.js HTTP/1.1", upstream: "http://[::1]:3000/f1be3f98162c975fdc9524a0a222f9a02cc6dcde.js", host: "website.com", referrer: "https://website.com/signIn"
I'm not really sure what's going on. Any help would be awesome.
Thanks!