nginx ssl redirect

Posted by Lari13 on Server Fault See other posts from Server Fault or by Lari13
Published on 2011-11-29T08:09:30Z Indexed on 2011/11/29 9:53 UTC
Read the original article Hit count: 219

Filed under:
|

I have SSL-sertificate for www. mydomain.com
How is the right config for nginx to get desired:

  • SSL request without www (https://mydomain.com/somefile) will be redirected to https://www. mydomain.com/somefile

This doesn't work, broser shows SSL-warning (wrong domain) :(

server
{
        listen  443 ssl;
        server_name mydomain.com;
        rewrite ^(.*) https://www.mydomain.com$1 permanent;
        ssl_certificate      intermediate.crt;
        ssl_certificate_key  www.mydomain.com.key;
}

© Server Fault or respective owner

Related posts about nginx

Related posts about ssl