WordPress behind NGINX on Docker not working

WordPress behind NGINX on Docker not working

So whilst migrating my full LAMP stack over to Docker, I had faced some issues whilst trying to move from an NGINX WordPress setup on my LAMP to a full Docker setup for my web based services.

I was using the LinuxServer.io deployment stacks (you can find these here via Portainer, however after I had setup WordPress I found that the when I attempted to restore a backup of the site to the new WordPress site, it would clonk out and not work.

What was the solution?

The solution was simple, in my case I ensured that the following code was inputted into my WP-Config:

define('FORCE_SSL_ADMIN', true);
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS']='on';

Also ensure that the following header is defined in your NGINX configuration file:

proxy_set_header X-Forwarded-Proto https;

Note: Remember to restart your Docker container after applying these changes.

Once these are done, you must straight away point your domain to the WordPress site BEFORE you install WordPress. Then in my case, I then uploaded my backup (created by UpdraftPlus )

I hope this helps you as I spent too many hours wracking my brain over why this wasn’t working where it was such a simple fix!