【问题标题】:Move nginx to different server将 nginx 移动到不同的服务器
【发布时间】:2016-01-26 19:15:30
【问题描述】:

我正在运行一个节点应用程序和 nginx 1.8.0。在同一台服务器上。 Nginx 使用

路由请求
server_name subdom.domain.com;

           location / {
           proxy_pass http://127.0.0.1:3000;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection 'upgrade';
           proxy_set_header Host      $host;
           proxy_set_header X-Forwarded-For $remote_addr;
   }

一切正常。我现在想将我的 nginx 放在不同的服务器上,将配置更改为:

server_name subdom.domain.com;

               location / {
               proxy_pass http://<ipofthenewserver>:3000;
               proxy_http_version 1.1;
               proxy_set_header Upgrade $http_upgrade;
               proxy_set_header Connection 'upgrade';
               proxy_set_header Host      $host;
               proxy_set_header X-Forwarded-For $remote_addr;
       }

我得到的只是“504 网关超时”。

【问题讨论】:

    标签: nginx


    【解决方案1】:

    我刚刚重新阅读了您的主题,您必须在新服务器中配置 nginx

      http://ipoftheoldserver:3000
    

    不是:

      http://ipofthenewserver:3000
    

    并确保端口应用程序 3000(在旧服务器中)在全球范围内开放。

    【讨论】:

    • 或者至少到运行 nginx 的服务器 ;-)
    【解决方案2】:

    如果后端服务器拒绝连接,您将收到“502 Bad Gateway”错误。

    有几种检查方法:

    1. 看看新的 nginx 服务器上发生了什么:tcpdump -i &lt;name_of_iface&gt; tcp and host &lt;ip_of_be_server&gt; and port 3000 -A
    2. 使用 curl 从新的 nginx 服务器向后端服务器发出请求
    3. 看看使用 tcpdump 在后端服务器上发生了什么

    等等

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-24
      • 2017-08-17
      • 1970-01-01
      • 1970-01-01
      • 2014-05-05
      • 2013-05-26
      • 1970-01-01
      • 2020-03-03
      相关资源
      最近更新 更多