小编fam*_*kin的帖子

当尾随斜杠不在 URI 中时,如何停止 nginx 301 自动重定向?

每次我在浏览器中尝试 foobar.com/test 时,nginx 似乎都会将客户端重定向(301)到 foobar.com/test/。这种行为是不可接受的。代理服务器是远程 Apache Web 服务器。我曾尝试直接调用 Apache 服务器(没有代理),但它不会重定向客户端。

考虑到下面的 nginx 服务器配置,知道我应该如何解决这个问题吗?

server {
        listen 80;
        server_name fooBar.com;

        location /test {
                proxy_redirect off;
                proxy_pass http://1.1.1.1:80/;
                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-Host $http_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;
        }


        location /test/ {
                proxy_redirect off;
                proxy_pass http://1.1.1.1:80/;
                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-Host $http_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;
        }
}
Run Code Online (Sandbox Code Playgroud)

nginx reverse-proxy 301-redirect apache-2.4

7
推荐指数
1
解决办法
1万
查看次数

Nginx 连接上游 Apache:重新协商握手失败

我正在配置将用作反向代理的新 Nginx 服务器。我们有运行 Apache 的旧 Debian 服务器。在这个 apache 服务器上,只有 HTTPS 访问的站点我想隐藏在代理后面。

从代理到上游 Apache 的连接必须通过 HTTPS(服务器位于不同的位置,Apache 只允许 HTTPS 访问)。

我的问题是从 Nginx 到 Apache 的连接失败。从浏览器到上游通过 HTTPS 的正常连接没有问题。从同一代理到 Nginx 上游的连接有效。当 Nginx 尝试连接到上游 Apache 连接失败并重新协商握手失败时

来自代理 Nginx 的日志(调试级别)仅表示:

2016/04/07 15:51:08 [error] 5855#0: *1 upstream prematurely closed connection while reading response header from upstream, client: 94.113.97.9, server: procrastination.com, request: "GET / HTTP/1.1", upstream: "https://77.240.191.234:443/", host: "procrastination.com"
Run Code Online (Sandbox Code Playgroud)

从上游 Apache 登录:

[Thu Apr 07 15:36:48 2016] [info] Initial (No.1) HTTPS request received for child 35 (server …
Run Code Online (Sandbox Code Playgroud)

nginx proxy https apache-2.2

3
推荐指数
1
解决办法
3959
查看次数