Solved: I found the solution to my problem here: https://serverfault.com/a/955471 This is the docker entry in my wp-config.php:
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
$_SERVER['HTTPS'] = 'on';}
but it seems, in my case it was not recognized, that my docker installation is behind a reverse proxy. I needed to write the "$_SERVER['HTTPS'] = 'on';" entry without the if query.
Edit: The Problem is not the migration, but it seems a wrong apache2 configuration
I am trying to migrate my wordpress site into docker. I have successfully inserted my database with the command:
docker exec -i wordpress_db_1 mysql -u exampleuser -pexamplepass exampledb < /home/dockerNutzer/datenbanken/wpdatabase.sql
and i have copied my old wp-content into the new Docker volume:
rsync -avc /home/dockerNutzer/wordpressSeite/wp-content/ /var/lib/docker/volumes/wordpress_wordpress/_data/wp-content/
The site is up and running, but it doesn't look like expected:
I can browse through the site, but when I try to log in, I get a redirect error from firefox with the message, that an error occurred during the connection with my address. A connection to a page like
/my-wordpress.site/?m=202210
is working, but not
/my-wordpress.site/wp-login.php
I am using the standard docker-compose file for installation:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8050:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
db:
image: mariadb:10.5
restart: always
ports:
- 3307:3306
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
volumes:
wordpress:
db:
I tried to clear the rewrite rules in the apache config file and the .htaccess file.
I tried to insert my whole old site into the docker volume and not only the wp-content folder.
Edit: I tried with this site https://ithemes.com/blog/wordpress-login-redirect-loop/ to fix the redirect loop. But it doesn't worked. I also checked the database with db check, like it is described here: https://ithemes.com/blog/error-establishing-database-connection/
It showed no error:
docker exec -i wordpressaltepw_wpcli_1 wp db check wpdatabase.wp_commentmeta OK wpdatabase.wp_comments OK
... Success: Database checked.