Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 部署反应器&;快速Nginx_Reactjs_Express_Nginx - Fatal编程技术网

Reactjs 部署反应器&;快速Nginx

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

我在nginx服务器上运行静态reactjs文件,在公共IP服务器上运行良好
http://118.98.232.227:8015
,我还想从nginx服务器运行express。在我的UI上,我已请求后端url
http://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中