Nginx Reverse Proxy Will Not Load HTTPS Sites

Ian asked:

Today has been the first time I’ve used Nginx. I got it set up as a dedicated reverse proxy by following a few guides. This is what I’m trying to recreate – http://www.integratedwebsystems.com/wp-content/uploads/2010/06/reverse_proxy.jpg

I have it working fine with port 80 but anything loaded over HTTPS gives me errors about HTTP content being insecure. Trying to load any HTTPS site over the reverse proxy via the internet looks very wrong. Loading it internally works just fine.

Example – http://i.imgur.com/i9mYgYe.png – That is supposed to be the WordPress admin console, it looks like something out of the 90s.

Below is the nginx config I’m using –

server {
   listen 80;
   server_name domain1.com;
   location / {
      proxy_pass http://192.168.1.149/;
      proxy_set_header Host $host;
   }
}

# HTTPS server

server {
    listen 443 ssl;
    server_name domain1.com;

    error_log /tmp/error.log;

        ssl on;
    ssl_certificate_key /etc/nginx/ssl/server.key;
    ssl_certificate /etc/nginx/ssl/server.crt;


    location / {
        proxy_pass http://192.168.1.149/;
        proxy_set_header Host $host;
    }
}

Can anyone advise me on what I’m missing to get HTTPS working correctly over the reverse proxy?

My answer:


You’re not missing anything; you configured nginx correctly.

The problem here is that WordPress thinks it should be generating HTTP links. When you try to access it via HTTPS, it still generates all of its links with http:// and thus they can’t be loaded (without explicitly loading insecure content in the browser).

There are WordPress plugins that will convert your admin console to https, if that is what you are trying to do. You could also edit your blog’s General Settings and convert the entire site to https quickly and easily, without a plugin.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.