未找到 Nginx 代理服务器 URL

未找到 Nginx 代理服务器 URL

一切都运行正常,除了当你想浏览网页时,因为当你点击一个链接时,它会用代理 URL 写入并且找不到任何结果。

例如,如果我想访问“http://<IP_PROXY_SERVER>:7050/app1/index.php/loremipsum”,它不起作用,但原始 URL 可以访问“http://<IP_ORIGINAL_SERVER>/index.pxp/loremipsum”。

这是我的配置:

server {
    listen 7050;
    listen [::]:7050;

    server_name 192.168.1.15:7050;

    location /app1 {
        proxy_pass http://192.168.1.200/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

代理尝试将 URL“翻译”为其自身,如“http://<IP_PROXY>:7050/index.php/loremipsum”,但无法访问(屏幕上会出现 404 错误)。

笔记:考虑到 URL 中的地址不再出现(app1)。如果您手动输入,它也不会起作用。

[error] 61731#61731: *160 open() "/etc/nginx/html/loremipsum/13" failed (2: No such file or directory), client: 192.168.1.100, server: 192.168.1.15:7050, request: "GET /loremipsum/13 HTTP/1.1", host: "192.168.1.15:7050", referrer: "http://192.168.1.15:7050/app2"

谢谢大家。


根据大家的建议,我可以手动输入“http://<SERVER_IP_PROXY>:7050/app1/<some_path>”,效果很好,也许“/app1”我必须手动输入。是否有某种工具可以保留路径上的位置?

答案1

尝试删除proxy_set_header Host $host;

最有可能的是,您的后端服务器没有配置反向代理的主机名。

相关内容