Wordpress Permalinks return 404 when using NGINX as a reverse proxy to apache Wordpress Permalinks return 404 when using NGINX as a reverse proxy to apache wordpress wordpress

Wordpress Permalinks return 404 when using NGINX as a reverse proxy to apache


I received this same error when I was migrating my Prod environment to Docker, using NGINX, but I was not reverse proxying for Apache. My error was the same, though.

The reason was that I had to change the wp_options to match my new local Port and URL.

SELECT * FROM wp_options WHERE option_name='siteurl' OR option_name='home'; will show you the current URL that your WordPress Config is trying to navigate to. But since you've created a Proxy and now have your WordPress site behind a different port or URL, you might need to change these values.

When you execute that command, you will receive a list of the two URLs that your site is using as your prefix. If it's showing the URL of the Proxy, this probably won't work.

I then modified the URLs to match the location of the NEW backend URL + Port. In your case, you will have to likely change it to match the port and url BEHIND the proxy, not the URL of the proxy itself.

Modifying these values inside my wp-config.php did NOT WORK. e.g.

 define('WP_HOME','http://local.www.greenhousetreatment.com:8080'); define('WP_SITEURL','http://local.www.greenhousetreatment.com:8080');

THIS DID NOT WORK FOR ME.

I had to manually use the command above in SQL, then UPDATE those values to match both the PORT and the URL of the website. Normally in reverse proxies, you will type in the Proxy URL, it will then hit your service IP, and port. Your service IP and PORT does what it needs to do, as it does not care at all about the proxy. It doesn't even know about the proxy.

Are you sure your wp_options match the actual service URL and PORT, and not the Proxy URL?

I hope this could shed some light.


Enable or check if mod_rewrite is enabled with this command

sudo a2enmod rewrite