Sorry for my bad English, I can't explain it well.
I have a VPS with Windows Server 2012 with Nginx and run a Node server at port 4000 and React client at port 3000.
In remote desktop website run at localhost address but when I use static IP of server in other device, I get any response from server.
This site can’t be reached XXX.XXX.192.176 took too long to respond.
I setup IIS and connected to the server, but when IIS is started, nginx can't start.
nginx is configured as follows:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name _;
location /api {
proxy_pass http://localhost:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /socket.io {
proxy_pass http://localhost:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
Finally I solved the problem:
I just add IP of server as server_name
and checked the windows firewall for port 80.
server {
listen 80;
server_name XXX.XXX.192.176; // IP of server
location /api {
proxy_pass http://localhost:4000;
}
location /socket.io {
proxy_pass http://localhost:4000;
}
location / {
proxy_pass http://localhost:3000;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}