最近我一直在尝试使用 Nginx 重定向到 HTTPS,但是在我尝试在浏览器中访问我的网站后,我不断收到重定向循环。这是我的完整服务器块配置文件:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
listen 443 ssl;
root /var/www;
index index.php index.html index.htm home.html contact.html projects.html;
# Make site accessible from http://localhost/
server_name melone.co;
return 301 https://$host$request_uri;
ssl_certificate /path/to/ssl;
ssl_certificate_key /path/to/ssl;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
proxy_set_header X-Forwarded-Proto $scheme;
}
error_page 404 /404.html;
# redirect server error pages to the …Run Code Online (Sandbox Code Playgroud)