运行 服务器静态IP中的nginx
Run nginx in static IP of server
对不起,我的英语不好,我解释不好。
我有一个 VPS 和 Windows Server 2012 with Nginx 和 运行 Node 服务器在端口 4000 和 React 客户端在端口 3000。
在本地主机地址的远程桌面网站 运行 但是当我在其他设备上使用服务器的静态 IP 时,我从服务器得到任何响应。
This site can’t be reached XXX.XXX.192.176 took too long to respond.
我设置了IIS并连接到服务器,但是当IIS启动时,nginx无法启动。
nginx配置如下:
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;
}
}
}
最后我解决了问题:
我只是将服务器 IP 添加为 server_name
并检查了 windows 防火墙的 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;
}
}
对不起,我的英语不好,我解释不好。
我有一个 VPS 和 Windows Server 2012 with Nginx 和 运行 Node 服务器在端口 4000 和 React 客户端在端口 3000。
在本地主机地址的远程桌面网站 运行 但是当我在其他设备上使用服务器的静态 IP 时,我从服务器得到任何响应。
This site can’t be reached XXX.XXX.192.176 took too long to respond.
我设置了IIS并连接到服务器,但是当IIS启动时,nginx无法启动。
nginx配置如下:
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;
}
}
}
最后我解决了问题:
我只是将服务器 IP 添加为 server_name
并检查了 windows 防火墙的 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;
}
}