I have a Node.js code deployed to Render; it works fine with Socket.IO. However, when I deploy it to my server, it connects to https://xx.io, but https://xx.io/api does not connect
i made this nginx file :
server {
listen 443 ssl;
server_name xx.io;
ssl_certificate /etc/ssl/certs/xx.crt;
ssl_certificate_key /etc/ssl/private/xx.key;
location /api {
rewrite ^/api(.*)$ $1 break;
proxy_pass http://localhost:3002;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_buffering off;
access_log /var/log/nginx/api_access.log;
error_log /var/log/nginx/api_error.log debug;
}
location /socket.io/ {
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_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:3002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_buffering off;
access_log /var/log/nginx/api_access.log;
error_log /var/log/nginx/api_error.log debug;
}
}
it connect to socket io in https://xx.io but https://xx.io/api didn’t ,how to fix it
New contributor
nginxx xxnx is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.