I'm trying to use traefik to route a path to a wordpress container. When I attempt to access "localhost/blog", I can see the url is routed to "http://localhost/wp-admin/install.php" but I get a 404 page not found error. Ideally, I'd like to have the wordpress container live at port 8002 and then tell traefik to direct requests to /blog to the wordpress container at 8002. The port thing really confuses me so I'm hoping someone can help me out. Here's my docker-compose file:
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