0

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:

enter image description here

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.

jochen
  • 13
  • 3
  • I wrote two answers that may be of use to you. First answer includes [deploying local docker compose project from database dumped sql file](https://stackoverflow.com/questions/65108253/docker-wordpress-seperate-default-plugins-from-own-plugins/65120181#65120181). Second answer is an [improved way of persistent wp files in your local docker compose project](https://stackoverflow.com/questions/70084875/how-do-i-configure-a-new-docker-compose-yml-file-in-an-existing-wordpress-git-re/70090353#70090353). Both answers include Mailhog which is awesome for capturing outgoing mail from your local env. – joshmoto Dec 23 '22 at 21:54

0 Answers0