PathStripPrefix don't work on ressources (css/js)

Viewed 855

I'm trying to configure my set-up with Traefik on docker. Everything if fine using Traefik + Portainer. But I lost so many hours trying to set Routes rules on Traefik.

'What I want ?"

  • My wordpress blog reachable at sub.domain.fr/wordpress

'What I have ?"

  • My wordpress is reachable, but every other ressources (scripts / css) are in 404. The main HTML worked, but CSS and scripts are on URL "sub.domain.fr/theme.css" instead of "sub.domain.fr/wordpress/theme.css" for example

  • For the first installation, i'm redirected to "sub.domain.fr/wp-admin/install.php", which is 404. Instead if I type "sub.domain.fr/wordpress/admin/install.php" i got a page (but without ressources like CSS).

Here's my docker-compose :

version: '3'

services:
  reverse-proxy:
    image: traefik # The official Traefik docker image
    command: --api --docker # Enables the web UI and tells Traefik to listen to docker
    ports:
      - "80:80"     # The HTTP port
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker
      - "/root/docker/traefik/traefik.toml:/etc/traefik/traefik.toml"
      - "/root/docker/traefik/log:/var/log/traefik"
      - "/root/docker/traefik/acme:/etc/traefik/acme"
    labels:
      - "traefik.enable=true"
      - "traefik.port=8080"
      - "traefik.frontend.rule=PathPrefixStrip: /traefik"
      - "traefik.frontend.entryPoints=http,https"
    networks:
      - traefik

  portainer:
    image: portainer/portainer
    networks:
      - "traefik"
    ports:
      - "9000:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    labels:
      - "traefik.enable=true"
      - "traefik.frontend.redirect.regex=^(.*)/portainer$$"
      - "traefik.frontend.redirect.replacement=$$1/portainer/"
      - "traefik.frontend.rule=PathPrefix:/portainer;ReplacePathRegex: ^/portainer/(.*) /$$1"
      - "traefik.port=9000"
      - "traefik.frontend.entryPoints=http,https"

  wordpress:
    image: wordpress
    links:
     - mariadb:mysql
    environment:
     - WORDPRESS_DB_PASSWORD=password
    volumes:
     - ./code:/code
     - ./html:/var/www/html
    labels:
     - "traefik.enable=true"
     - "traefik.port=80"
     - "traefik.frontend.rule=PathPrefixStrip:/wordpress"
     - "traefik.frontend.entryPoints=https"
    networks:
     - "traefik"


  mariadb:
    image: mariadb
    environment:
     - MYSQL_ROOT_PASSWORD=password
     - MYSQL_DATABASE=wordpress
    volumes:
     - ./database:/var/lib/mysql
    labels:
     - "traefik.enable=false"
    networks:
     - "traefik"

volumes:
  portainer_data:

networks:
  traefik:
    external:
      name: traefik

I don't have redirect all HTTP to HTTPS on the traefik.toml. Trying Path/PathPrefix --> Not worked. I'm reading tons of documentation but it seems that i'm the only with this "simple" problem. Do you have a solution ?

Thank you

Damien

0 Answers
Related