我有一个网站在LEMP堆栈上运行。我已经在网站上启用了cloudflare。我正在为https使用cloudflare灵活的SSL证书。当我用chrome打开网站时,它显示的网站被重定向了太多次,并且在firefox中检测到服务器以永远不会完成的方式重定向该地址的请求。我试图看到其他问题的答案,但他们似乎都没有解决问题。 NGINX conf文件: -HTTP到HTTPS Nginx太多重定向
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name mydomain.com www.mydomain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
location/{
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
如果有人能指出我做错了什么,我将非常感激。
我假设你正在使用CloudFlare的灵活的SSL选项HTTPS投放内容,你没有一个安全的服务器阻止你的Nginx配置。看看https://serverfault.com/questions/653976/redirect-loop-using-cloudflares-flexible-ssl/654018#654018 –