WordPress SSL Behind Ubuntu Reverse Proxy

Add the following to your proxy server’s virtual host file replacing http://your-wordpress-ip-address-or-url/ with your wordpress ip address or url and the locations to your ssl certs

<VirtualHost *:443>
SSLEngine On
SSLProxyEngine On
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://your-wordpress-ip-address-or-url/
ProxyPassReverse / http://your-wordpress-ip-address-or-url/
ServerName www.antigopc.com
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/website.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/website.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

Add the following to your wp-config.php right before /* That’s all, stop editing! Happy blogging. */

* Handle SSL reverse proxy
if ( (!empty( $_SERVER['HTTP_X_FORWARDED_HOST'])) ||
(!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) ) {
$_SERVER['HTTPS'] = 'on';

That’s it, WordPress will now understand it should serve as HTTPS and would add its https protocol properly.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.