WordPress Behind Apache Reverse Proxy

Note: This is a recovered post from my old blog. See how we recovered these posts using the Wayback Machine and AI tooling.

How to configure WordPress behind an Apache reverse proxy with SSL. I wanted to pull my sites out of the cloud and self-host them, which meant using a reverse proxy to manage multiple domains behind a single IP address.

On the Apache Reverse Proxy:

<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName domain.com
ServerAlias www.domain.com
RequestHeader set X-Forwarded-Proto "https"
ProxyPreserveHost On
DocumentRoot /var/www/html
ProxyPass /.well-known !
ProxyPass / http://1.2.3.4/
ProxyPassReverse / http://1.2.3.4/
SSLCertificateFile /Path/to/your/key/fullchain.pem
SSLCertificateKeyFile /Path/to/your/key/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{ENV:URI}/$1 [L,R=301]
SSLProxyEngine On
</VirtualHost>
</IfModule>

On WordPress, install the plugin “SSL Insecure Content Fixer” and configure it appropriately.

On WordPress, change the domain to “https” and remove “wordpress” from the directory. Fix the directory on the WordPress server by modifying the Apache config:

DocumentRoot /var/www/html/wordpress

Reload Apache and it should work.