【问题标题】:nginx 404 page shows wrong versionnginx 404页面显示错误的版本
【发布时间】:2016-06-24 17:08:08
【问题描述】:

我的nginx版本是1.4.6:

root@jung-digital:~# nginx -v
nginx version: nginx/1.4.6 (Ubuntu)

我已经设置了一个反向代理到一个版本为 1.8.0 的服务器,通过点击该服务器上的无效路径来确认。

但是,我的反向代理在尝试使用反向代理时显示了一个 HTML 页面:

404 Not Found

nginx/1.4.1 (Ubuntu)

到底发生了什么事?我的反向代理服务器和代理的目标服务器都没有使用 nginx 1.4.1。

对于那些好奇的人,这里是我的 nginx.conf 中的相关部分:

upstream ireport_dyndns {
    server ireport.somedomain.org;
}
...
server {
   listen 80;
   server_name ireport.somedomain2.com;
   access_log /var/log/nginx/ireport.access.log;

   root /var/www/ireport.somedomain2.com/dist;
   index index.html index.htm;

   location /api/ {
       add_header 'Access-Control-Allow-Origin' '*';
       add_header 'Access-Control-Allow-Methods' 'POST,GET,OPTIONS';
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-NginX-proxy true;
       proxy_pass http://ireport_dyndns/api/;
       proxy_ssl_session_reuse off;
       proxy_set_header Host $http_host;
       proxy_redirect off;
   }
}

【问题讨论】:

    标签: nginx http-status-code-404 reverse-proxy


    【解决方案1】:

    发现这一定是nginx的一个bug。代理服务器的配置更改正在检查 HOST 标头,而我的 proxy_pass 设置发送了错误的 HOST,因此代理服务器返回 404。

    来自代理服务器的响应在标头中指定 NGINX 1.8.0,但在正文中指定 1.4.1。

    nginx 中的错误。

    【讨论】:

      猜你喜欢
      • 2021-06-05
      • 2021-12-11
      • 1970-01-01
      • 2012-11-22
      • 2012-07-12
      • 1970-01-01
      • 1970-01-01
      • 2013-08-27
      相关资源
      最近更新 更多