title: Multiple Hosts wordpress docker with Traefik
body: <p><strong>Hello !</strong></p>
  <p>I have a question about Traefik using Docker and docker-compose,</p>
  <p>Indeed, I want to use traefik as a reverse proxy to redirect several services (in my case, several wordpress instances).</p>
  <p>Traefik works and I can access to a wordress instance (Wordpress, Mysql, PhpMyadmin) without any problem (with automatic https redirection),</p>
  <p>However, when I launch another Wordpress stack at the same time (WP, Mysql, PhpMyadmin), I can't access any service, I get a 404 error.</p>
  <p>Here is my traefik.yaml :</p>
  <pre><code>entryPoints:
    web:
      address: &quot;:80&quot;
      http:
        redirections:
          entryPoint:
            to: websecure
            scheme: https
  
    websecure:
      address: &quot;:443&quot;
      http:
        tls:
          certResolver: myresolver
        middlewares:
          - SecHeaders@file
  
  api:
    dashboard: true
  
  accessLog: {}
  
  providers:
    docker:
      exposedByDefault: false
  
    file:
      directory: /etc/traefik/custom/
      watch: true
  
  certificatesResolvers:
    myresolver:
      acme:
        email: &quot;mail@domain&quot;
        storage: &quot;/letsencrypt/acme.json&quot;
        tlsChallenge: {}
  
  </code></pre>
  <p>Here is my docker-compose.yaml for traefik :</p>
  <pre><code>version: &quot;3.7&quot;
  services:
    reverse_proxy:
      image: traefik:2.2
      restart: unless-stopped
      command:
        --api.insecure=true
        --providers.docker
        --entrypoints.web.address=:80
      ports:
        # The HTTP port
        - &quot;80:80&quot;
        # The HTTPS port
        - &quot;443:443&quot;
      volumes:
        # So that Traefik can listen to the Docker events
        - /var/run/docker.sock:/var/run/docker.sock
        # traefik static configuration
        - ./traefik.yaml:/etc/traefik/traefik.yaml:ro
        # custom folder with dynamic configuration
        - ./custom:/etc/traefik/custom:ro
        # ssl volumes to store acme.json
        - certs:/letsencrypt
  
      labels:
        - &quot;traefik.enable=true&quot; 
        - &quot;traefik.http.routers.traefik-api.rule=Host(`traefik.DOMAIN`)&quot; 
        - &quot;traefik.http.routers.traefik-api.service=api@internal&quot; 
  
      networks:
        - default
  
  volumes:
    certs:
  
  networks:
    default:
      external:
        name: gateway
  
  </code></pre>
  <p>Here is my docker-compose.yaml for wordpress:</p>
  <pre><code>version: '3'
  services:
  
    database:
      image: mysql:5.7
      container_name: bdd
      volumes:
        - ./BDD/file.sql:/docker-entrypoint-initdb.d/init.sql
        - db_data:/var/lib/mysql
      restart: always
      environment:
        MYSQL_ROOT_PASSWORD: passwd
        MYSQL_DATABASE: db
        MYSQL_USER: user-db
        MYSQL_PASSWORD: passwd-bdd
      networks:
        - network1
      labels:
        - traefik.enable=false
  
    phpmyadmin:
      depends_on:
        - database
      image: phpmyadmin
      container_name: pma
      restart: always
      environment:
        PMA_HOST: database
        MYSQL_PASSWORD: passwd-bdd
        MYSQL_ROOT_PASSWORD: passwd
      networks:
        - default
        - network1
      labels:
        traefik.enable: true
        traefik.http.routers.phpmyadmin.entrypoints: websecure
        traefik.http.routers.phpmyadmin.rule: 'Host(`pma.MY_DOMAIN`)'
  
    wordpress:
      depends_on:
        - database
      image: wordpress:5.7.1-php7.3
      container_name: wordpress
      restart: always
      volumes:
        - ./WORDPRESS:/var/www/html
      environment:
        WORDPRESS_DB_HOST: database:3306
        WORDPRESS_DB_USER: user-db
        WORDPRESS_DB_PASSWORD: passwd-bdd
        WORDPRESS_DB_NAME: db
        WORDPRESS_TABLE_PREFIX: wp_
      networks:
        - default
        - network1
      labels:
        traefik.enable: true
        traefik.docker.network: default
        traefik.http.routers.wordpress.entrypoints: websecure
        traefik.http.routers.wordpress.rule: 'Host(`mas.MY_DOMAIN`)'
  networks:
    default:
      external:
        name: gateway
    network1:
      internal: true
  volumes:
    db_data:
  </code></pre>
  <p>Here is my docker-compose.yaml for the 2nd wordpress:</p>
  <pre><code>version: '3'
  services:
    database2:
      image: mysql:5.7
      container_name: bdd2
      volumes:
        - ./SQL/file2.sql:/docker-entrypoint-initdb.d/init.sql
        - db_data2:/var/lib/mysql
      restart: always
      environment:
        MYSQL_ROOT_PASSWORD: passwd2
        MYSQL_DATABASE: db2
        MYSQL_USER: user-db2
        MYSQL_PASSWORD: passwd-bdd2
      networks:
        - network2
    phpmyadmin2:
      depends_on:
        - database2
      image: phpmyadmin
      container_name: pma2
      restart: always
      environment:
        PMA_HOST: database2
        MYSQL_PASSWORD: passwd-bdd2
        MYSQL_ROOT_PASSWORD: passwd2
      networks:
        - default
        - network2
      labels:
        traefik.enable: true
        traefik.http.routers.phpmyadmin.entrypoints: websecure
        traefik.http.routers.phpmyadmin.rule: 'Host(`pma.MY_DOMAIN2`)'
  
    wordpress2:
      depends_on:
        - database2
      image: wordpress:5.7.1-php7.3
      container_name: wordpress2
      restart: always
      volumes:
        - ./WP:/var/www/html
      environment:
        WORDPRESS_DB_HOST: database2:3306
        WORDPRESS_DB_USER: user-db2
        WORDPRESS_DB_PASSWORD: passwd-bdd2
        WORDPRESS_DB_NAME: db2
        WORDPRESS_TABLE_PREFIX: wp_
      networks:
        - default
        - network2
      labels:
        traefik.enable: true
        traefik.docker.network: default
        traefik.http.routers.wordpress.entrypoints: websecure
        traefik.http.routers.wordpress.rule: 'Host(`wordpress.MY_DOMAIN2`)'
  
  networks:
    default:
      external:
        name: gateway
    network2:
      internal: true
  
  volumes:
    db_data2:
  </code></pre>
  <p>Thanks for your help !</p>