Skip to content
Advertisement

WordPress on Docker behind nginx reverse proxy using SSL

Here is my problem,

I need to install a wordpress application on a subdirectory url (“https://test.com/blog/”). Since my whole environment is running on Docker, I decided to do the same with the wordpress app.

To start it as simple as possible, I added the wordpress image to my docker-compose.yml, and made a subdomain (“http://blog.test.com” which was not using https) fall on the application with my nginx reverse proxy.

It worked well and I installed my wordpress like that.

Now I’m trying to migrate this to my initial need and my problem is that everything works “well”, unless I can’t access the admin url (https://test.com/blog/admin) because it keeps redirects on https://test.com/blog/wp-admin and I get a “Too many redirects” error.

Here is my nginx configuration :

JavaScript

I also added the following at the top of wp-config.php file in the wordpress container :

JavaScript

What I noticed is if I try to print the $_SERVER variable by doing

var_dump($_SERVER);

in wp-config.php, there isn’t any of the nginx proxy variables.

Here is the output :

JavaScript

Do you have any idea ?

Advertisement

Answer

Actually I found my way through it ! I had an error in my nginx configuration and if anyone is interested, here is my final working configuration :

nginx.conf file (wordpress bloc) :

JavaScript

Here is what I added at the top of wp_config.php file of my wordpress container :

JavaScript

Cheers !

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement