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?
Related
I'm deploying my project, I had no problem until i decided to buy a domain for my digital ocean droplet i added the records from my namecheap domain to my droplet i was working on it then suddenly when i want access to myproject/api it's now showing 502 errors i'll give you all the informations so maybe you can help me with it
1 ) mongoDB atlas status : All good ; i even tried " npm start " to see if DB can't connect but it connects perfectly fine. I refreshed in .env the connecting string, it stills connect with no problems.
2 ) Nginx error.log shows this information i don't really understand, i guess it's the key point :
86 connect() failed (111: Connection refused) while connecting to upstream, client: 164.92.206.160, server: _, request: "GET /api/category/cinema HTTP/1.1", upstream: "http://[::1]:8000/api
3 ) The front is perfectly showing himself on my project domain url it starts showing 502 error when i click something using my DB/server.
4 ) i rebuilded and restarted front & back + nginx multiple times
5 ) i updated endpoints and .env variables to match with my fresh domain and it works, only the API side is breaking
6 ) nginx conf file :
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name _;
location /api {
proxy_pass http://localhost:8000;
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;
}
location / {
proxy_pass http://localhost: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;
}
I tried barely everything and it's still not working as it was used to work.
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?
I want to host a Nodejs API server to my digitalocean server where a WordPress application is already running using Nginx and PHP fpm
I followed the below link to set up the WordPress application and it's working fine now.
https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-web-server-and-reverse-proxy-for-apache-on-one-ubuntu-18-04-server
I wanted to set up Nodejs application inside the same server for demo purposes and I followed the digitalocean guide for setting up node js with a different config file and subdomain.
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04
My Nginx config for node application looks like this
server {
server_name sub.domain.com
location / {
proxy_pass http://localhost:6969;
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;
}
}
I have allowed port 6969 using ufw allow 6969.
I am able to access the Nodejs application using sub.domain.com:6969 but sub.domain.com gives me a 404 error. (404 Not Found nginx/1.18.0 (Ubuntu))
I want to access Nodejs application directly without a port number. I have checked Nginx logs and there are no errors, and configures is gives success in nginx -t
Please give me some suggestions to debug and fix this issue. I don't have much knowledge in Nginx configuration. I was just following tutorials from Digitalocean to configure the WordPress and node application.
Thanks in Advance
You are missing the port
server {
server_name sub.domain.com;
listen: 80;
location / {
proxy_pass http://localhost:6969;
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;
}
I am using Socket.io in a webpage, but it doesn't work. In the console.log I get the following error:
socket.io.js:2 WebSocket connection to 'ws://www.somewebpage.com/socket.io/?EIO=3&transport=websocket&sid=uoSGxATXKabezBn8AABP' failed: Error during WebSocket handshake: Unexpected response code: 400
I have this Nginx configuration:
location / {
proxy_pass http://melo;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
What can I check to solve this?
I am running node.js and socket.io on EC2, using nginx v1.4.1
Here is my /etc/nginx/sites-available/default
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name mysite.com;
location / {
proxy_pass http://localhost:4321;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
However I get
WebSocket connection to 'ws://mysite.com/socket.io/1/websocket/nS7f2eI5jAZ-pIN_8fai' failed: Unexpected response code: 502
and from node:
debug - setting request GET /socket.io/1/websocket/nS7f2eI5jAZ-pIN_8fai
debug - set heartbeat interval for client nS7f2eI5jAZ-pIN_8fai
warn - websocket connection invalid
Then it switches to xhr-polling.
I have followed exactly how so many online guides say about Nginx + websocket, but I don't know where I made a mistake.
As per the Nginx documentation, you can try the following in your nginx config file.
location /wsapp/ {
proxy_pass http://your-host:your-port/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}