Docker Community Forums

Share and learn in the Docker community.

Issues with wordpress container behind nginx rev proxy

Hello,

I am running wordpress in official container on an ubuntu 16.04 server with Docker version 17.05.0-ce, build 89658be. This is my docker command:

> docker run -it -d \
>   --name wordpress \
>   --restart=always \
>   -p 90:80 \
>   -e PUID=33 -e PGID=33 \
>   -e TZ=Europe/Berlin \
>   -v /docker/data/wordpress:/var/www/html  \
>   wordpress

To access it from internet I am using a Nginx container with this part of config file:

   location ^~ /blog {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
       proxy_pass http://192.168.100.10:90/;
       proxy_redirect off;
   }

wp-config.php file is added with these lines:

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
        $_SERVER['HTTPS']='on';

if(isset($_SERVER['HTTP_X_FORWARDED_HOST']))
        $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];

define('WP_HOME', 'https://myserver.com/blog');
define('WP_SITEURL', 'https://myserver.com/blog');

I am able to access it with myserver.com/blog
configuration and link to mariadb is working well.
If I am accessing it after all of this with
myserver.com/blog/wp-admin

I see admin page but all links which I can click at this page are like

https://myserver.com//wp-admin/options-writing.php

the “blog” between// is missing.
I tried so much and wasted hundreds of kW electricity googling for a solution.
Hopefully you can help me a little please.

Thanks a lot

Hi!

Same problem for me and i tried a rewrite, for me it’s okay but after doesn’t load some css and js files.

rewrite ^/blog/(.*) /blog/$1 break;