Dimitrios Desyllas Dimitrios Desyllas - 3 months ago 15
Apache Configuration Question

Cannot login with wp-cli generated user wordpress behind reverse proxy

Hello fellows I have made a custom wordpress image located there: https://github.com/ellakcy/wordpressWithPlugins

And on entrypoint script I am using wp-cli in order to generate a custom user in order to preinstall plugins. But I cannot login to the control panel with the generated user from wp-cli.

Do you have any Idea how to fix it?

The entrypoint of the script is the following: https://github.com/ellakcy/wordpressWithPlugins/blob/master/docker-entrypoint.sh

I run the containers with these commands: (for development purpose)


docker run --name wpdb -e MYSQL_ROOT_PASSWORD=1234 -d mariadb
docker run --name mywordpress --link wpdb:mysql -p 8080:80 -ti wp


And I am using apache as reverse proxy in order to access the wordpress running in the mywordpress container:

<VirtualHost *:80>

ProxyPass / http://172.17.0.3/
ProxyPassReverse http://172.17.0.3/ /

</Virtualhost>


(In place of 172.17.0.3 can be the ip of the container running the wordpress)

Edit 1



I managed to login by setting up a network:


docker network create --subnet="172.19.0.0/16" wordpress_default


And setting the custom ips to the coontainers. (Also I set some Enviromental variables too.)


RUN MYSQL/MARIADB



docker run --name wpdb --net wordpress_default --ip 172.19.0.2 -e MYSQL_ROOT_PASSWORD=1234 -d mariadb

run wordpress docker with some extra enviiromental variables



docker run --name mywordpress --net wordpress_default --ip 172.19.0.3 --link wpdb:mysql -e WORDPRESS_ADMIN_PASSWORD=1234 -e WORDPRESS_ADMIN_EMAIL=pc_magas@openmailbox.org -e WORDPRESS_URL=172.19.0.3 -p 8080:80 -ti wp


And visiting the wordpress site via the ip given oon the second coommand. But I still have problems with the local apache running as reverse proxy.

Answer

In the end just manually setting the machine's ip as url works like a charm.

docker run --name wpdb --net wordpress_default --ip 172.19.0.2 -e MYSQL_ROOT_PASSWORD=1234 -d mariadb
run wordpress docker with some extra enviiromental variables

docker run --name mywordpress --net wordpress_default --ip 172.19.0.3 --link wpdb:mysql -e WORDPRESS_ADMIN_PASSWORD=1234 -e WORDPRESS_ADMIN_EMAIL=pc_magas@openmailbox.org -e WORDPRESS_URL=172.19.0.3 -p 8080:80 -ti wp

All I had to do wat to set the following vhost to my apache:

<VirtualHost *:80>

RequestHeader set X-Forwarded-Proto "http"

ProxyPass /  http://172.19.0.3/
ProxyPassReverse  http://172.19.0.3/ /

</Virtualhost>

(Perhaps for production may need some changes)

Comments