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

I want to rewrite https requests to https://www to https://. I'm trying to do something like this, but it doesn't seem to work for https:

server {
   listen 443;

   ssl on;
   ssl_certificate /etc/ssl/sslchain.crt;
   ssl_certificate_key /etc/ssl/domain.key;

   server_name www.nginx.com;
   rewrite ^ https://nginx.com$request_uri permanent;
}
share|improve this question
    
What kind of error are you actually getting? –  cjc Aug 25 '11 at 17:56
1  
My certificate only works with the nginx.com version of the URL so then Firefox has that certificate warning page saying the certificate isn't trusted... –  johannix Aug 25 '11 at 18:26

1 Answer 1

If you are getting an SSL warning, you will need separate certs for www.example.com and example.com: these are different entities, as far as the certificate is concerned (i.e., the server name must match the Common Name for the certificate exactly).

One option may be to use Subject Alternate Names, though, depending on the type of browsers you expect to visit your site, that may not work (i.e., mobile browsers may be more finicky). This essentially allows one certificate to be used for several different server names.

If you've already bought your cert, that may be a problem, too.

share|improve this answer
    
As stated I had to create/download another certificate for the www subdomain since I also had another subdomain that was using a different cert. –  Keith Smiley Mar 7 at 16:14

Your Answer

 
discard

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.