http - nginx 将每个 http 请求重定向到 https

标签 http redirect ssl https nginx

最后我切换到 nginx 网络服务器。但是每次我访问例如 http://mywebsite.com 时,它都会将我重定向到 https://mywebsite.com。我的服务器 block (vhost) 中没有任何 ssl 选项。这是一个精简版(只删除了帮助评论):

server {
        listen 80;
        root /usr/share/nginx/www/mywebsite/htdocs;
        index index.php index.html index.htm;
        server_name mywebsite.com;

        location / {
                try_files $uri $uri/ /index.html;
        }
        location ~ \.php$ {
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param CONTEXT Staging;
                include fastcgi_params;
        }
}

我真的不知道我是否在正确的地方搜索错误?!

PS:PHP 返回给我 ["SERVER_PROTOCOL"]=> string(8) "HTTP/1.1"

多谢指教!

最佳答案

明白了!我在我的 /etc/nginx/fastcgi_params 中找到了我注释掉的 fastcgi_param HTTPS $https; 行。现在,它工作正常。希望对其他人有所帮助。

关于http - nginx 将每个 http 请求重定向到 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19549915/

相关文章:

http - 哪个开源负载均衡器支持 SPDY?

java - 是否有一种解决方案可以在重定向响应时在浏览器上保留 cookie?

wordpress - anchor 标记中的onclick和href重定向

ssl - 自定义域连接上的 socket.io `net::ERR_INSECURE_RESPONSE`——与 Openshift url 一起使用

php - 切换到 SSL 后登录 PHP session

http - 对于单个请求,http/2 相对于 http 的性能优势

java - 如何在 Java 中防止 403 HTTP 错误代码?

http - 临时维护页面的最佳实践方法和状态代码是什么?

redirect - 直接链接与重定向

ssl - 尝试在 C-Panel 中安装免费 SSL(使用 https ://zerossl. com/)后出现 404 错误