I have failed to remove www. How can I achieve it?
This is traefik v2.3.5 docker-compose.yml
file.
version: "3.7"
services:
traefik:
image: traefik:v2.3.5
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- 80:80
- 443:443
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik.yml:/traefik.yml:ro
- ./acme.json:/acme.json
labels:
- "traefik.enable=true"
# global redirection: https (www.) to https
- "traefik.http.routers.wwwsecure-catchall.rule=HostRegexp(`{host:(www\\.).+}`)"
- "traefik.http.routers.wwwsecure-catchall.entrypoints=websecure"
- "traefik.http.routers.wwwsecure-catchall.tls=true"
- "traefik.http.routers.wwwsecure-catchall.middlewares=wwwtohttps"
# middleware: http(s)://(www.) to https://
- "traefik.http.middlewares.wwwtohttps.redirectregex.regex=^https?://(?:www\\.)?(.+)"
- "traefik.http.middlewares.wwwtohttps.redirectregex.replacement=https://$${1}"
- "traefik.http.middlewares.wwwtohttps.redirectregex.permanent=true"
# v2.3.5 config
- "traefik.http.routers.traefik.rule=Host(`traefik.domain.com`)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=password"
- "traefik.http.routers.traefik-secure.rule=Host(`traefik.domain.com`)"
- "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=http"
- "traefik.http.routers.traefik-secure.service=api@internal"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
# gzip compression
- "traefik.http.routers.traefik.middlewares=traefik-compress"
- "traefik.http.middlewares.traefik-compress.compress=true"
networks:
proxy:
external: true
This is container's docker-compose.yml
file.
version: '3.7'
services:
bodrum-web:
image: docker-image-url
container_name: bodrum-web
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data:/data
labels:
- "traefik.enable=true"
- "traefik.http.routers.bodrum-web.entrypoints=http"
- "traefik.http.routers.bodrum-web.rule=Host(`domain.com`) || Host(`www.domain.com`)"
- "traefik.http.middlewares.bodrum-web-https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.bodrum-web.middlewares=bodrum-web-https-redirect"
- "traefik.http.routers.bodrum-web-secure.entrypoints=https"
- "traefik.http.routers.bodrum-web-secure.rule=Host(`domain.com`) || Host(`www.domain.com`)"
- "traefik.http.routers.bodrum-web-secure.tls=true"
- "traefik.http.routers.bodrum-web-secure.tls.certresolver=http"
- "traefik.http.routers.bodrum-web-secure.service=bodrum-web"
- "traefik.http.services.bodrum-web.loadbalancer.server.port=80"
- "traefik.docker.network=proxy"
# gzip compression
- "traefik.http.middlewares.bodrum-compress.compress=true"
- "traefik.http.routers.bodrum-web.middlewares=bodrum-compress"
networks:
proxy:
external: true