【问题标题】:nginx with multiple locations not working - error 404具有多个位置的 nginx 不起作用 - 错误 404
【发布时间】:2019-04-12 03:20:07
【问题描述】:

我正在设置 nginx 以使用代理服务两个网站,如下所示,

server {
listen                 80;

proxy_set_header HOST $proxy_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;

location / {
    proxy_pass http://<website-1>;
    proxy_read_timeout 300;
}

location /bmo {
    proxy_pass http://<website-2>;
    proxy_read_timeout 300;
}

}

到 website-1 的代理正在工作,但 website-2 出现错误 404。请告诉我如何解决这个问题。

【问题讨论】:

  • 代理是否有效?那么你能在website-2 上看到访问权限吗(例如在日志文件中)?
  • 访问日志收到此消息:"GET /favicon.ico HTTP/1.1" 404 570 "awspad12345.com/bmo" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" "-" awspad12345.com 是配置 nginx 的服务器。

标签: nginx nginx-location nginx-reverse-proxy nginx-config


【解决方案1】:

您得到 404 代码,因为第二个站点缺少路径 /bmo,对吗?

在您的示例 url 中代理到 http://&lt;website-2&gt;/bmo

代理上的Nginx配置有效且正确,请检查website-2上的配置

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-12
    • 2013-07-31
    • 1970-01-01
    • 1970-01-01
    • 2021-10-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-16
    相关资源
    最近更新 更多