我想重定向我的https://www.example.com到我的https://example.com域。我管理它做一个没有SSL的重定向https://,但当我添加到我的域400错误被抛出。
这是我的网站-可用:
server {
error_log /var/log/nginx/error.log debug;
root /var/www/project;
index index.html;
server_name example.ch;
location / { try_files $uri $uri/ =404;}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.ch/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.ch/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = example.ch) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name example.ch;
listen 80;
return 404; # managed by Certbot
}
server {
server_name www.example.ch;
return 301 $scheme://example.ch$request_uri;
}
1条答案
按热度按时间68bkxrlz1#
我认为你需要为你的www域添加一个ssl证书,如果你想让https工作。即使你只是想要一个重定向-但如果你请求网站,它会先做tls握手,当一个安全的连接建立起来,它会发送重定向到客户端。因此,在没有为该子域配置SSL的情况下,您无法从
https://www.example.ch
发送任何响应。尝试获取证书,最后一个块应该像这样扩展: