【发布时间】:2017-05-25 18:49:17
【问题描述】:
我有一个在 LEMP 堆栈上运行的网站。我已经在网站上启用了 cloudflare。我正在为 https 使用 cloudflare 灵活的 SSL 证书。当我在 chrome 中打开网站时,它显示网站重定向您太多次,并且在 Firefox 中检测到服务器正在以永远不会完成的方式重定向对该地址的请求。我试图查看其他问题的答案,但似乎都没有解决问题。 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 配置中没有安全服务器块。看看serverfault.com/questions/653976/…