Traefik and nginx 404 page not found

Hello,

I receive 404 http error when I want to use Traefik with Nginx. If I deploy just nginx, it's work, but when I add traefik configuration, I receive 404. I'm open for any suggestions Thanks!

Version:      v1.7.14
Codename:     maroilles
Go version:   go1.12.8
Built:        2019-08-14_09:46:58AM
OS/Arch:      linux/amd64
logLevel = "DEBUG"

[traefikLog]
  filePath = "/var/log/traefik/traefik.log"
  format   = "json"

[accessLog]
  filePath = "/var/log/traefik/access.log"
  format = "json"

defaultEntryPoints = ["http", "https"]

[entryPoints]
  [entryPoints.dashboard]
    address = ":8080"
    [entryPoints.dashboard.auth]
      [entryPoints.dashboard.auth.basic]
        users = ["xxxxxx:xxxxxxxxxxxxxxxxxxx"]
  [entryPoints.http]
    address = ":80"
      [entryPoints.http.redirect]
        entryPoint = "https"
  [entryPoints.https]
    address = ":443"
      [entryPoints.https.tls]
[api]
entrypoint="dashboard"

[acme]
email = "info@xxxxx.com"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
  [acme.httpChallenge]
  entryPoint = "http"

[docker]
domain = "xxxxxxxxxxx.com"
watch = true
network = "traefik"
services:
  traefik:
    image: traefik:v1.7.6-alpine
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    networks:
      - traefik
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /root/tomas/traefik/traefik.toml:/traefik.toml
      - /root/tomas/traefik/acme.json:/acme.json
      - /var/log/traefik:/var/log/traefik

networks:
  traefik:
    external: true
services:
  nginx:
    image: nginx:alpine
    user: root
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./html:/usr/share/nginx/html
      - ./conf.d/nginx.conf:/etc/nginx/nginx.conf
      - /var/log/nginx:/var/log/nginx
    networks:
      - traefik
    labels:
      traefik.enable: 'true'
      traefik.backend: nginx
      traefik.port: '80'
      traefik.frontend.rule: Host:xxxx.xxxx.com
      traefik.domain: womoapp.eu
      traefik.frontend.protocol: https
      traefik.frontend.redirect.entryPoint: https
      traefik.frontend.redirect.permanent: 'true'
    deploy:
      mode: replicated
      replicas: 2

networks:
  traefik:
    external: true
{"level":"debug","msg":"Creating server server-stack-nginx-1-vbbqhfen6up3dx0r3tvkfgtbd-aaeff304a0d8ae08bbe9b1b159d1a653 at http://10.0.3.160:80 with weight 1","time":"2019-08-31T11:40:07Z"}
{"level":"debug","msg":"Creating server server-stack-nginx-2-vj4nig145c7pdt4yr3r9vsskv-f4b51c4646a9712e087e082650abe316 at http://10.0.3.161:80 with weight 1","time":"2019-08-31T11:40:07Z"}
{"level":"debug","msg":"Creating route route-frontend-Host-xxxxx-xxxxx-com-1 Host:xxxxx-xxxxx-com","time":"2019-08-31T11:40:07Z"}
{"level":"debug","msg":"Wiring frontend frontend-Host-xxxxx-xxxxx-com-2 to entryPoint http","time":"2019-08-31T11:40:07Z"}
{"level":"debug","msg":"Reusing backend backend-nginx [http - docker - frontend-Host-xxxxx-xxxxx-com-2 - 8318482181067170285]","time":"2019-08-31T11:40:07Z"}
{"level":"debug","msg":"Creating route route-frontend-Host-xxxxx-xxxxx-com-2 Host:xxxxx-xxxxx-com","time":"2019-08-31T11:40:07Z"}
{"level":"debug","msg":"Add certificate for domains xxxxx-xxxxx-com","time":"2019-08-31T11:40:07Z"}
{"level":"info","msg":"Server configuration reloaded on :8080","time":"2019-08-31T11:40:07Z"}
{"level":"info","msg":"Server configuration reloaded on :80","time":"2019-08-31T11:40:07Z"}
{"level":"info","msg":"Server configuration reloaded on :443","time":"2019-08-31T11:40:07Z"}
{"BackendAddr":"","BackendName":"Traefik","BackendURL":{"Scheme":"","Opaque":"","User":null,"Host":"","Path":"/","RawPath":"","ForceQuery":false,"RawQuery":"","Fragment":""},"ClientAddr":"10.255.0.2:58713","ClientHost":"10.255.0.2","ClientPort":"58713","ClientUsername":"-","DownstreamContentSize":19,"DownstreamStatus":404,"DownstreamStatusLine":"404 Not Found","Duration":118892,"FrontendName":"backend not found","OriginContentSize":19,"OriginDuration":9924,"OriginStatus":404,"OriginStatusLine":"404 Not Found","Overhead":108968,"RequestAddr":"xxxxx-xxxxx-com","RequestContentSize":0,"RequestCount":9,"RequestHost":"xxxxx-xxxxx-com","RequestLine":"GET / HTTP/2.0","RequestMethod":"GET","RequestPath":"/","RequestPort":"-","RequestProtocol":"HTTP/2.0","RetryAttempts":0,"StartLocal":"2019-08-31T11:42:45.853198974Z","StartUTC":"2019-08-31T11:42:45.853198974Z","downstream_Content-Type":"text/plain; charset=utf-8","downstream_X-Content-Type-Options":"nosniff","level":"info","msg":"","origin_Content-Type":"text/plain; charset=utf-8","origin_X-Content-Type-Options":"nosniff","request_Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3","request_Accept-Encoding":"gzip, deflate, br","request_Accept-Language":"ro-RO,ro;q=0.9,en-US;q=0.8,en;q=0.7,it;q=0.6,pt;q=0.5,fr;q=0.4,ar;q=0.3,es;q=0.2,de;q=0.1","request_Cache-Control":"max-age=0","request_Sec-Fetch-Mode":"navigate","request_Sec-Fetch-Site":"none","request_Sec-Fetch-User":"?1","request_Upgrade-Insecure-Requests":"1","request_User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36","time":"2019-08-31T11:42:45Z"}

Hello,

defaultEntryPoints is missplaced: TOML is not indentation based.

logLevel = "DEBUG"
defaultEntryPoints = ["http", "https"] <---

[traefikLog]
  filePath = "/var/log/traefik/traefik.log"
  format   = "json"

[accessLog]
  filePath = "/var/log/traefik/access.log"
  format = "json"


[entryPoints]
  [entryPoints.dashboard]
    address = ":8080"
    [entryPoints.dashboard.auth]
      [entryPoints.dashboard.auth.basic]
        users = ["xxxxxx:xxxxxxxxxxxxxxxxxxx"]
  [entryPoints.http]
    address = ":80"
      [entryPoints.http.redirect]
        entryPoint = "https"
  [entryPoints.https]
    address = ":443"
      [entryPoints.https.tls]

[api]
entrypoint="dashboard"

[acme]
email = "info@xxxxx.com"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
  [acme.httpChallenge]
  entryPoint = "http"

[docker]
domain = "xxxxxxxxxxx.com"
watch = true
network = "traefik"

I recommend to update your Traefik from traefik:v1.7.6-alpine to traefik:v1.7.14-alpine.

Also you can remove some labels:

version: "3.3"

services:
  nginx:
    image: nginx:alpine
    user: root
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./html:/usr/share/nginx/html
      - ./conf.d/nginx.conf:/etc/nginx/nginx.conf
      - /var/log/nginx:/var/log/nginx
    networks:
      - traefik
    labels:
      - "traefik.enable=true"
      - "traefik.backend=nginx"
      - "traefik.port=80"
      - "traefik.frontend.rule=Host:xxxx.xxxx.com"
    deploy:
      mode: replicated
      replicas: 2

networks:
  traefik:
    external: true
1 Like