Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Redirect Nginx将https www重定向到https非www_Redirect_Ssl_Nginx - Fatal编程技术网

Redirect Nginx将https www重定向到https非www

Redirect Nginx将https www重定向到https非www,redirect,ssl,nginx,Redirect,Ssl,Nginx,我的域名mydomain.com没有www。 Nginx配置: server { server_name www.mydomain.com; return 301 $scheme://mydomain.com$request_uri; } 所有重定向都可以正常工作,除了https://www.mydomain.com -> https://mydomain.com. 每个浏览器都会向我显示一条带有以下消息的警报: This Connection is Untruste

我的域名mydomain.com没有www。 Nginx配置:

server
{
    server_name  www.mydomain.com;
    return 301 $scheme://mydomain.com$request_uri;
}
所有重定向都可以正常工作,除了https://www.mydomain.com -> https://mydomain.com. 每个浏览器都会向我显示一条带有以下消息的警报:

    This Connection is Untrusted

    You have asked Firefox to connect securely to www.mydomain.com, 
but we can't confirm that your connection is secure.

我该怎么办?

不,不可能。HTTPS是SSL内部的HTTP,因此要首先获得HTTP重定向,必须建立并验证SSL连接,如果您不使用浏览器不信任的证书(例如自签名证书),或者主机名与证书不匹配,则SSL连接将失败。

您有证书吗https://mydomain.com?Yes,我有驾驶执照https://mydomain.com...and https://www.mydomain.com 也是?你在mydomain.com上使用重定向吗?这可能就是问题所在——从mydomain.com开始的重定向是通过HTTP而不是HTTPS进行的。另外,请使用example.com,不要使用mydomain.com。IANA为此保留了它。不,我没有www.mydomain.com的证书。