【问题标题】:NGINX proxy_pass not foundNGINX proxy_pass 未找到
【发布时间】:2019-09-18 22:41:40
【问题描述】:

我尝试了以下 SO 答案,但没有成功 This onethis one 和其他一些。我也查看了文档,但是我无法弄清楚我做错了什么。当我点击 / 时,我得到了 nginx 主页(很好)。当我尝试点击 /alpha 时,我得到 404。冰壶到 127.0.0.1:5001 给了我我对主机的期望。谁能告诉我我错过了什么?

配置:

  http {
         server {
                listen 80;

                location /prealpha/ {
                        proxy_pass http://127.0.0.1:5000/;
                }
                location /alpha/ {
                        proxy_pass http://127.0.0.1:5001/;
                }
                location /beta/ {
                        proxy_pass http://127.0.0.1:5002/;
                }
                location /gamma/ {
                        proxy_pass http://127.0.0.1:5003/;
                }
        }

更新 来自 nginx 调试输出的以下日志似乎表明 keepalive 无法正常工作,然后连接被关闭。我是否需要使用上游或其他东西来使连接保持打开状态?

2019/09/18 12:11:03 [debug] 8688#8688: *2 http upstream request: "/alpha/?"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http upstream process header
2019/09/18 12:11:03 [debug] 8688#8688: *2 malloc: 000055B88E563AE0:4096
2019/09/18 12:11:03 [debug] 8688#8688: *2 recv: eof:0, avail:1
2019/09/18 12:11:03 [debug] 8688#8688: *2 recv: fd:9 484 of 4096
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy status 404 "404 NOT FOUND"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Server: gunicorn/19.7.1"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Date: Wed, 18 Sep 2019 12:11:03 GMT"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Connection: close"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Content-Type: text/html"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Content-Length: 232"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Set-Cookie: oidc_id_token=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly; Path=/"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header: "Vary: Cookie"
2019/09/18 12:11:03 [debug] 8688#8688: *2 http proxy header done
2019/09/18 12:11:03 [debug] 8688#8688: *2 xslt filter header
2019/09/18 12:11:03 [debug] 8688#8688: *2 posix_memalign: 000055B88E538C60:4096 @16
2019/09/18 12:11:03 [debug] 8688#8688: *2 HTTP/1.1 404 NOT FOUND
Server: nginx/1.14.0 (Ubuntu)
Date: Wed, 18 Sep 2019 12:11:03 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: oidc_id_token=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly; Path=/
Vary: Cookie
Content-Encoding: gzip

重大更新

事实证明,nginx 正在将位置选择器(不确定 htis 实际称为什么,但在顶部的配置中它是显示“/prealpha/”的位)传递给 proxy_pass URL。我需要它不要那样做。它需要简单地将该点之后的所有内容传递给代理。我如何让它做到这一点?

【问题讨论】:

  • 您在没有斜杠的情况下点击位置,但您的 location 只能使用斜杠。当你点击/alpha/(希望尾部斜杠)时,结果是什么。
  • 我刚收到 404。
  • 访问日志显示它是 404 但没有错误日志。

标签: nginx


【解决方案1】:

最终,https://serverfault.com/a/379679/356031 修复了它。

简而言之,没有错误日志并且请求被清楚地传递(一旦我在 nginx 中启用了调试日志记录),然后在我在 gunicorn 中启用调试日志记录后表明正在传递错误的 url。

【讨论】:

    猜你喜欢
    • 2015-01-04
    • 2019-01-22
    • 2023-03-08
    • 2021-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-25
    • 1970-01-01
    相关资源
    最近更新 更多