NGINX将所有内容重定向到https,但一个目录除外

时间:2015-09-21 14:33:41

标签: redirect ssl nginx https

我已经搜索了stackoverflow寻找答案以及所有建议的内容,我已经尝试过没有成功。

我的网站将用户重定向为始终使用SSL(https)。但是,我有一个无法在SSL上运行的聊天应用程序,因为它未使用ssl url获得许可。我无法让开发人员更新许可证,但这是另一个故事。

因此,我允许非ssl(http)只是这个聊天应用程序,它位于一个名为chat的子目录中。

这是我的配置,它不起作用:

$(document).ready(function () {

    $('.section-down-arrow-wrap.scroller').on('click', function () {

        var fuller = $(this).closest('.fullscreen').next('.fullscreen'),
            section = $(this).closest('.section');

        section.animate({
            scrollTop: fuller.offset().top + 0
        }, 700);

    });

});

我尝试过多种组合,包括302而不是301(在尝试此操作时清除浏览器缓存),尾随斜杠与非尾随斜杠。似乎没什么用。

在我更新SSL块以获得更安全并获得A +标签之前,这曾经是疯狂的。不确定我删除或添加的内容可能会影响到这一点。

最后,如果我清除浏览器缓存,直接转到

  

server { listen 80; location / { # the default location redirects to https return 301 https://$server_name$request_uri; } location /chat/ {} # do not redirect requests for chat location # ... } server { listen 443; location /chat/ { # redirect https iframe requests to http server return 301 http://$server_name$request_uri; } # ... }

,它没有重定向哪个是正确的。但是,一旦我转到https://example.com,然后转到http://example.com/chat/test.htm,浏览器就会显示无限重定向。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

看起来我在我的SSL块中添加了HSTS标头,告诉浏览器强制使用SSL。这导致无休止的重定向。我将HSTS指令的年龄更改为0,因此希望这会重置我的用户浏览器。

相关问题