Nginx不会将http重定向到https
问题描述:
我无法弄清楚这一点。你能帮我吗?Nginx不会将http重定向到https
这是我的设置:
服务器上的单个网站。
去http://工作正常,直到我将https:// ...设置添加到我的网站配置。
去https:// ...现在工作正常。
去http:// ...现在只是超时。
server {
listen 80;
server_name mywebsite.io www.mywebsite.io;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name mywebsite.io www.mywebsite.io;
root /var/www/mywebsite.io/public_html;
index index.html index.htm;
ssl on;
ssl_certificate /etc/ssl/certs/cert_chain.crt;
ssl_certificate_key /etc/ssl/certs/mywebsite.key;
}
我在做一些愚蠢的事情吗?
干杯
答
尝试:
server {
listen 80;
server_name mywebsite.io www.mywebsite.io;
return 301 https://$host$request_uri;
}
由于$server_name
是模糊的,当你有一个以上。
我修复了这个问题。这似乎是一个更新阻止端口80.疯了。我现在重新开放了这个端口。 –