【发布时间】:2018-03-06 21:53:47
【问题描述】:
我想将我的所有http 流量重定向到https。我正在使用letsencrypt。我在网上看到return 301 https://$server_name$request_uri; 会将所有到我网站的流量重定向到https,但结果却是ERR_TOO_MANY_REDIRECTS。
没有上面提到的声明一切正常,但是我必须在 URL 中特别指定https。这是我的/etc/nginx/sites-available/default 文件:
server {
listen 80 default_server;
listen 443 ssl default_server;
ssl_certificate /etc/letsencrypt/live/mywebsite.me/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mywebsite.me/privkey.pem;
root /home/website/mywebsite/public;
index index.html index.htm index.php;
server_name mywebsite.me www.mywebsite.me;
return 301 https://$server_name$request_uri;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
}
}
我哪里错了?
【问题讨论】: