Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Greetings everyone!

I have a weird issue with nginx. I want to redirect all traffic that comes from to I also want to redirect the secure one: https:// to https://

My config is:

server {
    listen           80;
    listen           443 ssl;
    rewrite        ^ $scheme://$request_uri? permanent;

and under here is a server section to handle the

The immediately gets redirected to

The secure one (https:// does not. I get a warning that the certificate is issued to etc.

Any suggestions are more than welcome!


FYI: I am new at this so I don't know how to accept answers and stuff so that people get points. Excuse the noobness :)

share|improve this question
up vote 1 down vote accepted

You cannot fix this. In order to make the request the server must establish a secure connection. During the course of establishing that connection, the client is seeing the invalid certificate ( != and is throwing the error. Your redirect code is never being seen by the client because it abandons the call before it gets past the headers. There is nothing you can do except to buy and use a new cert for and then do the redirect.

share|improve this answer
Thank you for the answer Jack. I thought I was going nuts about it. – Nikolaos Dimopoulos Mar 30 '11 at 21:42
+1, I just found this out the hard way. :) Got a non-wildcard certificate, was trying to redirect to a non-www, and of course it doesn't match my cert. Oh well... – Cyclops Oct 24 '11 at 14:11

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.