加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

NGINX代理传递给NodeJS应用程序:返回502错误

发布时间:2020-12-13 21:16:02 所属栏目:Nginx 来源:网络整理
导读:我正在尝试将NGINX设置为我的NodeJS应用程序的前端,该应用程序在127.0.0.1:3000上运行,但我无法解决此502错误. NGINX可在本地访问,网址为http://55.55.55.5/或http://dev.example dev.example(文件位于:/ etc / nginx / sites-available和符号链接到启用了

我正在尝试将NGINX设置为我的NodeJS应用程序的前端,该应用程序在127.0.0.1:3000上运行,但我无法解决此502错误. NGINX可在本地访问,网址为http://55.55.55.5/或http://dev.example

dev.example(文件位于:/ etc / nginx / sites-available和符号链接到启用了网站)

upstream up_dev.example {
    server 127.0.0.1:3000;
}

server {
    listen 0.0.0.0:80;
    server_name dev.example example;
    access_log /var/log/nginx/dev.example.log;

    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://up_dev.example/;
      proxy_redirect off;
    }
 }

error.log中

2014/09/17 19:38:26 [error] 1679#0: *1 connect() failed (111: Connection refused) while connecting to upstream,client: 55.55.55.1,server:,request: “GET / HTTP/1.1”,upstream:$

最佳答案
它也可能是SELinux,因为httpd_can_network_connect默认关闭,所以阻止了连接.

getsebool httpd_can_network_connect

检查是否已打开.如果没有,请通过运行将其打开

setsebool -P httpd_can_network_connect on

-P表示持久性更改,因此即使重新启动后,新布尔值仍然有效.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读