How to run WordPress Blog behind Nginx Secure (https) Proxy

When I started this blog, I was asked, what was the most annoying thing I get while setup up a WordPress blog. I can’t really get SSL thing out of my head – yet. It was totally worth it.

When running a WordPress behind a proxy, it will give an error of unable to complete the request.

There are kinds of problem you will see:

  1. WordPress homepage is stuck in an endless loop.
  2. CSS/JS files are not loading.
  3. Transport error.


Editing Nginx for WordPress behind Proxy

Add following proxy configuration in your Nginx

proxy_set_header X-Forwarded-Proto https;

Your nginx configuration should look more or less like:

    location / {
        try_files $uri @app;
    location @app {
        proxy_set_header X-Forwarded-Proto https;
        include .common/proxy.common;

Config for SSL enabled WordPress behind Proxy

There is a possibility that you might need to add the following as well in wp-config.php file in some versions of WordPress.

if($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){

    $_SERVER['HTTPS'] = 'on';
    $_SERVER['SERVER_PORT'] = 443;

Do you have wp-config.php inside Docker?

If your wp-config.php file is under Docker, then you can use docker cp command to copy/copy back file.

#Copy from docker container
docker cp project_wordpress_1:/var/www/html/wp-config.php .

#Copy to docker container
docker cp wp-config.php project_wordpress_1:/var/www/html/wp-config.php

Worth Sharing?


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>