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 already use nginx as a proxy to redirect from

http://www.mydomain.com ==> http://192.168.0.1

but when I try to redirect

https://www.mydomain.com ==> https://192.168.0.1

it does not work !

my nginx.conf:

server {
  listen 443;
  server_name www.mydomain.com;

  location / {
    proxy_pass https://192.168.0.1;
  }
}

when I go to https://192.168.0.1 it works fine ! nginx is on 192.168.0.2 (another machine).

what did I do wrong ?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You aren't redirecting, right? The browser continues to say www.mydomain.com, it opens a connection with your nginx server which in turn opens a connection to the machine it is actually handling the request, that machine sends its response to nginx and nginx sends it back to the client.

Since nginx is the one actually talking to the client it will need an SSL connection between itself and the client. The internal SSL connection on your network isn't necessarily necessary unless you are worried about your internal networks security.

You'll have to use nginx ssl module. http://wiki.nginx.org/NginxHttpSslModule

server {
    server_name www.mydomain.com;
    listen 443;
    ssl on;
    ssl_certificate /usr/local/nginx/conf/server.crt;
    ssl_certificate_key /usr/local/nginx/conf/server.key;
    location / {
        proxy_pass https://192.168.0.1;
    }
}

Your current setup probably will work on http://mydomain.com:443 since it is a non ssl connection.

share|improve this answer
add comment

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.