Nginx www. -> 根 SSL 重定向

Nginx www. -> 根 SSL 重定向

我以 DINORSAUR.COM 为例,我实际上并不拥有它

尝试弄清楚如何让 https:// www.dinosaur.com 重定向到 https:// dinosaur.com 我有 www.dinosaur.com 的证书和 *.dinosaur.com 的通配符证书。有什么想法吗?当我尝试直接转到 https:// www.dinosaur.com 时,我收到“此网页不可用”的消息,但 http:// www.dinosaur.com 可以正常工作 这是我的配置

server{
        listen          80 default_server;
        server_name     ~^(?<sub>\w+\.)?(?<domain>dinosaur\.com)$;
        rewrite         ^ https://$sub$domain$request_uri;
}
server{
        listen 443 ssl;
        server_name www.dinosaur.com;
        return 301 https://dinosaur.com;
        ssl on;
        ssl_certificate /etc/ssl/certs/www.dinosaur.com.crt;
        ssl_certificate_key /etc/ssl/private/www.dinosaur.com.key;
        ssl_protocols SSLv3 TLSv1;
        ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;
        client_max_body_size 0;
}
server{
        # THIS IS WHERE I WANT ALL TRAFFIC TO GO
        listen 443 ssl;
        server_name dinosaur.com  *.dinosaur.com;
        access_log /root/logs/access.log;
        error_log /root/logs/error.log;

        ssl on;
        ssl_certificate /etc/ssl/certs/chained.dinosaur.com.crt;
        ssl_certificate_key /etc/ssl/private/dinosaur.com.key;
        ssl_protocols SSLv3 TLSv1;
        ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;
        client_max_body_size 0;
}

相关内容