Little issue with name and access

I use traefik as reverse proxy for my little server.
The behaviour is a little weird:

  • when i connect to www.website.com it redirect to website.com and serve content from the backend (hugo server container)
  • when i connect to website.com i got a 404 error like if no backend

I use a * dns entry to redirect all subdomains to the public ip address of traefik
i successfully have a git.website.com/jenkins.website.com/portainer.website.com....but only www.website.com redirect to website.com (url displayed/rewritten in my chrome url bar) and when i want to directly connect to website.com then 404.
both website.com and www.website.com resolve to the same ip address.

my config.toml

################################################################
# Global configuration
################################################################


insecureSkipVerify = true
defaultEntryPoints = ["http", "https"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

[acme]
email = "tech@citoyx.com"
storageFile = "/etc/traefik/acme/acme.json"
entryPoint = "https"
OnHostRule = true
onDemand = true

[[acme.domains]]
  main = "citoyx.com"
  sans = ["portainer.citoyx.com", "traefik.citoyx.com", "git.citoyx.com"]


[acme.httpChallenge]
entryPoint= "http"

[web]
address = ":8080"
[web.auth.basic]
  users = ["dpac:$apr1$PJnuGmZy$8EEW3ng/LbZsDnF3NGhzw/"]

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "citoyx.com"
watch = true
exposedbydefault = true

And my docker-compose:

services:
  proxy:
    image: traefik:v1.7.16
    networks:
      - traefik
    ports:
      - "80:80"
      - "8080:8080"
      - "443:443"
    volumes:
      -  "$PWD/traefik.toml:/etc/traefik/traefik.toml"
      -  "$PWD/acme:/etc/traefik/acme"
      - /var/run/docker.sock:/var/run/docker.sock
    restart: unless-stopped
    labels:
      - "traefik.frontend.rule=Host:traefik.citoyx.com"
      - "traefik.port=8080"
      - "traefik.backend=traefik"
      - "traefik.frontend.entryPoints=http,https"

  portainer:
    image: portainer/portainer
    networks:
      - traefik
    labels:
      - "traefik.frontend.rule=Host:portainer.citoyx.com"
      - "traefik.port=9000"
      - "traefik.backend=portainer"
      - "traefik.frontend.entryPoints=http,https"
    volumes:
        - "/var/run/docker.sock:/var/run/docker.sock"
    restart: unless-stopped

  www:
    image: citoyx/hugo
    networks:
      - traefik
    labels:
      - "traefik.frontend.rule=Host:www.citoyx.com"
      - "traefik.port=1313"
      - "traefik.backend=hugo"
      - "traefik.frontend.entryPoints=http,https"
    volumes:
      - "/data/work/hugo:/srv/hugo"
    environment:
      - HUGO_BASEURL=https://www.citoyx.com
    ports:
      - "1313:1313"
    restart: unless-stopped

Nobody can help me on this issue ?

If you click on your address bar and press Home button it will display you the actual URL, assuming chrome. I do not think that it does the redirect, you are describing.

You can also use curl to examine headers / redirects to see what's happening. If you expect website.com NOT to return 404 you need a rule to account for that and it does not look like you have one.

1 Like

where can i find documentation about those kind of rule ?

https://docs.traefik.io/v1.7/basics/#matchers

1 Like

I fixed, it works,
thank you !