Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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) :(

        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;
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Since ssl handshake and certificate check occurs before any HTTP communication there is no way to make redirect without browser's warning.

share|improve this answer
Apart from getting another certificate for the second domain. –  Ladadadada Nov 29 '11 at 9:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.