Varun Priolkar

Getting SSL reverse proxy to work with WordPress

This is not very hard to do but I had a tough time figuring out how to get this to work. I’m just writing this down in case someone finds it helpful.

In this scenario I’m running Nginx as the reverse proxy with SSL enabled on it and WordPress on a separate Nginx server in the backend. This should work with Apache2 in the backend too. Migrating existing setups will work with this or if you are doing a fresh install you can either do the setup over non-SSL or use SSL, run the setup and then do the “On the backend server” part.

On the reverse proxy

In your Nginx vhost put this at the top:

In the server block put this in. This will be your location block. Configure SSL as normal.

If you are using Let’s Encrypt make sure you put this in the server block.

Replace /var/www/blog with webroot for the certbot plugin and set permissions with chown -R www-data:www-data /path/to/webroot. Make sure you replace www-data with appropriate Nginx user/group.

On the backend server

In the webroot of your WordPress install open up the wp-config.php file and add in the following above the require_once(ABSPATH . ‘wp-settings.php’); line.

Set permissions with chown -R www-data:www-data /path/to/webroot. Make sure you replace www-data with appropriate backend web server user/group.

That’s it! Everything right from forwarded IPs to vhosts with different server blocks with different server_name directives on the backend server should just werk now. 😛

ra6pu

I hope you found this useful. Do let me know if you have any suggestions/need any help. 😀

1 Comment

  1. Hi
    thank you for nice tutorial.
    After i changed all the setting, the page is reachable. 🙂
    But if i click on one button it doesn’t take me to the next site

    “The requested URL /about/ was not found on this server.
    Apache/2.4.10 (Debian) Server at regenata-institut.kara-network.ch Port 80”

    Have you any idea why? 🙂

    Thanks

Leave a Reply