我正在尝试在Docker上使用Traefik配置我的设置。使用Traefik + Portainer一切都很好。 但是我花了很多时间试图在Traefik上设置Routes规则。
“我想要什么?”
“我有什么?”
我的wordpress可以访问,但是其他所有资源(脚本/ css)都在404中。主要的HTML可以工作,但是CSS和脚本位于URL“ sub.domain.fr/theme.css”上,而不是“例如sub.domain.fr/wordpress/theme.css
对于首次安装,我被重定向到“ sub.domain.fr/wp-admin/install.php”,即404。而是如果我键入“ sub.domain.fr/wordpress/admin” /install.php”,我得到了一个页面(但没有像CSS这样的资源)。
这是我的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
我没有在traefik.toml上将所有HTTP重定向到HTTPS。 尝试Path / PathPrefix->不起作用。 我正在阅读大量文档,但看来我是唯一遇到此“简单”问题的人。 你有解决方案吗 ?
谢谢
达米恩