昨天我更改了我的域名帽子是 foobar.tk 并且它运行在 https 上。现在,在我的新域 foobar.eu 上我没有 ssl。
我在不使用 https 时使用 CNAME 记录成功重定向,但不知何故我无法重定向 https://www.example.tk至 http://www.example.eu Chrome 表示连接已重置。 Firefox 表示无法验证内容,...
对于重定向,我使用这些行:
server {
listen 443; (note: i have tried with *:443, *:443 ssl, 443 ssl)
server_name www.example.tk; (i have tried with orwithout www.)
return 301 http://www.example.eu$request_uri; (i have tried to redir to $host also where then cname will handle the issue)
}
什么有效:
http://www.example.tk -> http://www.example.eu使用 CNAME(和所有其他子域)
什么不起作用:
https://www.example.tk -> http://www.example.eu
我仍然可以备份证书,所以如果它能以某种方式帮助我,请告诉我。
谢谢
最佳答案
在 Nginx 上设置 SSL 时,您应该使用 ssl_certificate
and ssl_certificate_key
directives .
server {
listen 443 ssl;
server_name www.example.tk;
ssl_certificate /path/to/certificate; #.crt, .cert, .cer, or .pem file
ssl_certificate_key /path/to/private/key;
return 301 http://www.example.eu$request_uri;
}
您可以从您的证书颁发机构获得这两个文件。
你还应该在 listen
指令中添加 ssl
参数。
关于redirect - NGINX 将旧的 https 域重定向到新的非 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35380348/