我正在尝试使用traefik将路径路由到wordpress容器。当我尝试访问“ localhost / blog”时,我可以看到URL路由到“ localhost / wp-admin / install.php”,但出现404页面未找到错误。理想情况下,我希望将wordpress容器放置在端口8002上,然后告诉traefik在8002处将请求/ blog定向到wordpress容器。该端口确实使我感到困惑,所以我希望有人可以帮助我。这是我的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
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker eventsdoc
networks:
- test_network
- internal
db:
image: mysql:5.7
volumes:
- db_data:/tmp/dbdata
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- test_network
- internal
wordpress:
depends_on:
- db
image: wordpress:latest
networks:
- test_network
- internal
ports:
- "8002:80"
labels:
- "traefik.backend=wordpress-example"
- "traefik.frontend.rule=Host:localhost;PathPrefixStrip:/blog"
- "traefik.docker.network=test_network"
- "traefik.enable=true"
- "traefik.port=80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
networks:
test_network:
external: true
internal:
external: false