Problem of migrating wordpress from V1.7 to V2

Hi everyone,

I am trying to migrate from v1.7 to v2. Everything I tested so far are working as intended except WordPress.

When I was trying to do it with v2, I can see below error message.

wordpress_1 | MySQL Connection Error: (2002) Connection refused

after a while, I was able to install WordPress successfully and logged in. however, when I tried to update a plugin or install plugin, I was getting below error.

Here is my docker-compose.yml file

version: '3.7'

services:
  traefik:
    image: traefik:latest
    container_name: traefik
    restart: always
    security_opt:
      - no-new-privileges:true
    ports:
      - 80:80
      - 443:443
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./data/traefik.yml:/traefik.yml:ro
      - ./data/acme.json:/acme.json
      # Add folder with dynamic configuration yml
      - ./data/configurations:/configurations
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik-secure.entrypoints=websecure"
      - "traefik.http.routers.traefik-secure.rule=Host(`traefik.example.com`)"
      - "traefik.http.routers.traefik-secure.middlewares=user-auth@file"
      - "traefik.http.routers.traefik-secure.service=api@internal"
      
  #Database for Wordpress
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: dbuser
      MYSQL_PASSWORD: dbpassword
      
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    restart: always
    volumes:
      - ./wordpress:/var/www/html/wp-content 
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: dbuser
      WORDPRESS_DB_PASSWORD: dbpassword
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.wordpress-secure.entrypoints=websecure"
      - "traefik.http.routers.wordpress-secure.rule=Host(`example.com`) || Host(`www.example.com`)"
      - "traefik.http.routers.wordpress-secure.middlewares=www-redirect@file"
      - "traefik.http.routers.wordpress-secure.service=wordpress-service"
      - "traefik.http.services.wordpress-service.loadbalancer.server.port=80"
      
volumes:
    db_data:      

http to https redirect was set up on traefik.yml file and middlewares were defined in dynamic configuration files.

Can anyone please tell me what I need to change to get WordPress working?

Thank you

I also use try the set up mentioned https://ip-life.net/docker-wordpress-traefik-2/

He set up traefik with external network and only put the wordpress container to that network. WordPress container connects the MySQL container via default network.

    networks:
      - traefik_default
      - default

This set up gives me the same error.

I've figured out the problem being the secureHeader middleware I used. :pensive: