【问题标题】:NGINX redirect old https domain to new non-httpsNGINX 将旧的 https 域重定向到新的非 https 域
【发布时间】:2016-02-13 13:15:29
【问题描述】:

昨天我更改了我的域名帽子是 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

我仍然可以备份证书,所以如果它在某些方面有帮助,请告诉我。

谢谢

【问题讨论】:

    标签: redirect ssl nginx


    【解决方案1】:

    在 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;
    }
    

    您可以从您的证书颁发机构获得这两个文件。

    您还应该将ssl 参数添加到listen 指令。

    【讨论】:

    • 谢谢,稍后回复,我今天会试试这个,如果有效,会接受
    猜你喜欢
    • 1970-01-01
    • 2018-04-27
    • 1970-01-01
    • 2019-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-18
    • 2015-04-01
    相关资源
    最近更新 更多