Tip for putting WordPress behind a reverse proxy

Tip for putting WordPress behind a reverse proxy

A while ago, I had fun putting this WordPress site behind a reverse proxy (limiting the IPv4 address available on my infrastructure), and I had some small problems with AJAX requests that no longer worked.

So I'm making a note below to help those who are also having problems in a similar setup

Adding CORS headers to the Apache vHost

I'm not going to describe here how to set up an Apache vHost to run a reverse proxy, that's not the topic of the day.

CORS (Cross-origin resource sharing) headers allow content to be uploaded to different addresses other than your site.

Apparently in WordPress it is necessary to manage this for the page editor to work properly.

Simply add these instructions to the vHost file (be careful to activate the Header module)

 Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE" Header set Access-Control-Allow-Headers "Content-Type, Authorization"

Once added, reload the Apache config, and you're done

sudo systemctl reload apache2