Reactjs 部署反应器&;快速Nginx
我在nginx服务器上运行静态reactjs文件,在公共IP服务器上运行良好Reactjs 部署反应器&;快速Nginx,reactjs,express,nginx,Reactjs,Express,Nginx,我在nginx服务器上运行静态reactjs文件,在公共IP服务器上运行良好http://118.98.232.227:8015,我还想从nginx服务器运行express。在我的UI上,我已请求后端urlhttp://localhost:5000/something我尝试使用npm run start从nginx运行express,它确实在http://localhost:5000,但浏览器错误连接被拒绝http://localhost:5000。然后我试着从本地主机而不是服务器上运行expr
http://118.98.232.227:8015
,我还想从nginx服务器运行express。在我的UI上,我已请求后端urlhttp://localhost:5000/something
我尝试使用npm run start从nginx运行express
,它确实在http://localhost:5000
,但浏览器错误连接被拒绝http://localhost:5000
。然后我试着从本地主机而不是服务器上运行express,显然它运行得非常好。为什么会这样?静态reactjs文件在nginx服务器上运行,而express在本地主机上运行
我想要的是从nginx和UI端通过http://localhost:5000
来自nginx服务器计算机,而不是我的本地主机。我希望你明白我的意思
这是我的/etc/nginx/可用站点/示例
upstream backend {
server localhost:5000;
}
server {
listen 8015;
server_name 118.98.232.227;
root /var/www/example;
index index.html;
location / {
try_files $uri /index.html =404;
}
}
我的reactjs静态文件位于/var/www/example中