NGINX重定向到http

时间:2016-01-28 08:17:41

标签: redirect nginx

我是NGINX的新手,一直试图解决这个问题。

NGINX配置在大多数情况下运行良好,但是当一个请求在末尾没有尾部斜杠时,它会重定向到http:// $ host而不是https:// $ host。它之前使用端口进行转发,但我关闭了port_in_redirect,它禁用了在浏览器中显示端口号。

不知怎的https://domain.com/xyz/abc仍然被重定向到http://domain.com/xyz/abc/

我的猜测是try_files以某种方式不保留域名

我确信配置中有问题,但我对最终导致它没有深刻的见解

非常感谢任何投入

    server {
    listen  8080;
    server_name _;

    location /xyz/abc {
            alias /var/www/html/;
            try_files $uri $uri/ /xyz/abc/index.html;
    }

    location ~ ^/xyz/foo/(.*) {
            return 301 https://$host/xyz/abc/foo/$1;
    }

下面是卷曲输出

curl -I https://domain.com/xyz/abc
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.3
Date: Thu, 27 Jan 2016 08:18:27 GMT
Content-Type: text/html
Content-Length: 184
Location: http://domain.com/xyz/abc/
Connection: keep-alive

0 个答案:

没有答案