Helloo. I'm trying to get Traefik to work with Strapi CMS system, but for some reason everytime I request a route eg. cms.example.com/ or cms.example.com/admin I get the same response. I can inspect the incomming request to Strapi via dcoker-compose output and it keeps outputting the request is for / and does not include the path requested.
I suspect Traefik is not sending this path through to the service. Can someone please confirm this or direct me as to how I can confirm that Traefik is indeed sending through the request path correctly
Here is how I configured my services:
- Created a docker network called web (to attach Traefik and services to attach to Traefik)
- Deploy a traefik instance with
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -v $PWD/traefik.toml:/traefik.toml -p 80:80 -p 443:443 -p 8080:8080 --network web --name traefik traefik:2.0.2
- Deploy Strapi via docker-compose
traefik.toml
################################################################
# Global configuration
################################################################
[global]
checkNewVersion = true
sendAnonymousUsage = true
################################################################
# Entrypoints configuration
################################################################
# Entrypoints definition
#
# Optional
# Default:
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.websecure]
address = ":443"
################################################################
# Traefik logs configuration
################################################################
# Traefik logs
# Enabled by default and log to stdout
#
# Optional
#
[log]
# Log level
#
# Optional
# Default: "ERROR"
#
level = "INFO"
# Sets the filepath for the traefik log. If not specified, stdout will be used.
# Intermediate directories are created if necessary.
#
# Optional
# Default: os.Stdout
#
filePath = "log/traefik.log"
# Format is either "json" or "common".
#
# Optional
# Default: "common"
#
format = "json"
################################################################
# Access logs configuration
################################################################
# Enable access logs
# By default it will write to stdout and produce logs in the textual
# Common Log Format (CLF), extended with additional fields.
#
# Optional
#
# [accessLog]
# Sets the file path for the access log. If not specified, stdout will be used.
# Intermediate directories are created if necessary.
#
# Optional
# Default: os.Stdout
#
# filePath = "/path/to/log/log.txt"
# Format is either "json" or "common".
#
# Optional
# Default: "common"
#
# format = "json"
################################################################
# API and dashboard configuration
################################################################
# Enable API and dashboard
[api]
# Name of the related entry point
#
# Optional
# Default: "traefik"
#
# entryPoint = "traefik"
# Enabled Dashboard
#
# Optional
# Default: true
#
dashboard = true
insecure = true
################################################################
# Ping configuration
################################################################
# Enable ping
[ping]
# Name of the related entry point
#
# Optional
# Default: "traefik"
#
# entryPoint = "traefik"
################################################################
# Docker configuration backend
################################################################
# Enable Docker configuration backend
[providers.docker]
# Docker server endpoint. Can be a tcp or a unix socket endpoint.
#
# Required
# Default: "unix:///var/run/docker.sock"
#
# endpoint = "tcp://10.10.10.10:2375"
# Default host rule.
#
# Optional
# Default: "Host(`{{ normalize .Name }}`)"
#
# defaultRule = "Host(`{{ normalize .Name }}.docker.localhost`)"
# Expose containers by default in traefik
#
# Optional
# Default: true
#
network = "web"
watch = true
exposedByDefault = false
Docker-Compose for Strapi
version: '3.1'
services:
wordpress-sl:
image: wordpress
restart: always
ports:
- 8000:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- compose_wordpress:/var/www/html
- $PWD/.htaccess:/var/www/html/.htaccess
labels:
- "traefik.enable=true"
- "traefik.backend=wordpress-sl"
- "traefik.http.routers.slimline.rule=Host(`slimline.xyz`)"
- "traefik.http.routers.slimline.entrypoints=web"
- "traefik.docker.network=web"
- "traefik.port=80"
networks:
- internal
- web
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- compose_db:/var/lib/mysql
networks:
- internal
volumes:
compose_wordpress:
external: true
compose_db:
external: true
networks:
web:
external: true
internal:
external: false