Treafik with nginx 404 error page - tried many things

Hello Team,

I am trying to figure out last a few days but I am not doing great, only what I got is 404 error.

I tried in my personal laptop, and DO droplet. same configuration. I have domain which I am using for testing,play.

i Traefik web interface

host and service have been named : traefik-traefik

Host(traefik-traefik)
traefik-traefik@docker

Traefuk.yml

################################################################
# API and dashboard configuration
################################################################
api:
  # Dashboard
  #
  #
  dashboard: true
  insecure: true
################################################################


# Docker configuration backend
################################################################
providers:
  docker: 
    watch: false
    exposedByDefault: true
    swarmMode: false
################################################################
# Traefik Logging
################################################################
log:
  level: DEBUG

entryPoints:
  web:
    address: ":80"
  websecure:
    address: ":443"

################################################################
# Challenge HTTP
################################################################
certificatesResolvers:
  myresolver:
    acme:
      email: zeenmc@gmail.com
      storage: acme.json
      httpChallenge:
        entryPoint: web

docker-compose.yml

--- 
version: '3.7'

services:
  traefik:
    # The latest official supported Traefik docker image
    image: traefik:v2.5
    # Enables the Traefik Dashboard and tells Traefik to listen to docker
    # enable --log.level=INFO so we can see what Traefik is doing in the log files
    ports:
      # Exposes port 80 for incomming web requests
      - "80:80"
      - "443:443"
      # The Web UI port http://0.0.0.0:8080 (enabled by --api.insecure=true)
      - "8080:8080"
    networks:
       - brote-network
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik.yml:/etc/traefik/traefik.yml
      - ./letsencrypt:/letsencrypt

  web: 
    image: "nginx"
#    ports: 
#      - "80:80"
#      - "443:443"
    networks:
       - brote-network
    restart: unless-stopped
    volumes: 
      - "./config/:/etc/nginx/conf.d/"
      - "./app:/var/www/html/"
      - "./ssl:/etc/ssl" 
      - "./letsencrypt:/letsencrypt"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.web.rule=Host(`ram,brote.dev`, `brote.dev`)"
      - "traefik.http.routers.web.entrypoints=secureweb"
      - "traefik.https.routers.web.service=web"
      - "traefik.https.services.web.loadbalancer.server.port=443"
      - "traefik.http.routers.web.tls.certresolver=myresolver"

networks:
  brote-network:
    external: true

Output :

traefik_1 | time="2021-10-15T23:16:28Z" level=info msg="Configuration loaded from file: /etc/traefik/traefik.yml"
traefik_1 | time="2021-10-15T23:16:28Z" level=info msg="Traefik version 2.5.3 built on 2021-09-20T15:43:56Z"
traefik_1 | time="2021-10-15T23:16:28Z" level=debug msg="Static configuration loaded {"global":{"checkNewVersion":true},"serversTransport":{"maxIdleConnsPerHost":200},"entryPoints":{"traefik":{"address":":8080","transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s"}},"forwardedHeaders":{},"http":{},"udp":{"timeout":"3s"}},"web":{"address":":80","transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s"}},"forwardedHeaders":{},"http":{},"udp":{"timeout":"3s"}},"websecure":{"address":":443","transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s"}},"forwardedHeaders":{},"http":{},"udp":{"timeout":"3s"}}},"providers":{"providersThrottleDuration":"2s","docker":{"endpoint":"unix:///var/run/docker.sock","defaultRule":"Host({{ normalize .Name }})","exposedByDefault":true,"swarmModeRefreshSeconds":"15s"}},"api":{"insecure":true,"dashboard":true},"log":{"level":"DEBUG","format":"common"},"certificatesResolvers":{"myresolver":{"acme":{"email":"zeenmc@gmail.com","caServer":"https://acme-v02.api.letsencrypt.org/directory","storage":"acme.json","keyType":"RSA4096","httpChallenge":{"entryPoint":"web"}}}},"pilot":{"dashboard":true}}"
traefik_1 | time="2021-10-15T23:16:28Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://doc.traefik.io/traefik/contributing/data-collection/\n"
traefik_1 | time="2021-10-15T23:16:28Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
traefik_1 | time="2021-10-15T23:16:28Z" level=debug msg="Start TCP Server" entryPointName=websecure
traefik_1 | time="2021-10-15T23:16:28Z" level=debug msg="Start TCP Server" entryPointName=traefik
traefik_1 | time="2021-10-15T23:16:28Z" level=debug msg="Start TCP Server" entryPointName=web
traefik_1 | time="2021-10-15T23:16:28Z" level=info msg="Starting provider *traefik.Provider {}"
traefik_1 | time="2021-10-15T23:16:28Z" level=debug msg="Configuration received from provider internal: {"http":{"routers":{"acme-http":{"entryPoints":["web"],"service":"acme-http@internal","rule":"PathPrefix(/.well-known/acme-challenge/)","priority":2147483647},"api":{"entryPoints":["traefik"],"service":"api@internal","rule":"PathPrefix(/api)","priority":2147483646},"dashboard":{"entryPoints":["traefik"],"middlewares":["dashboard_redirect@internal","dashboard_stripprefix@internal"],"service":"dashboard@internal","rule":"PathPrefix(/)","priority":2147483645}},"services":{"acme-http":{},"api":{},"dashboard":{},"noop":{}},"middlewares":{"dashboard_redirect":{"redirectRegex":{"regex":"^(http:\\/\\/(\\[[\\w:.]+\\]|[\\w\\.-]+)(:\\d+)?)\\/$","replacement":"${1}/dashboard/","permanent":true}},"dashboard_stripprefix":{"stripPrefix":{"prefixes":["/dashboard/","/dashboard"]}}},"serversTransports":{"default":{"maxIdleConnsPerHost":200}}},"tcp":{},"tls":{}}" providerName=internal
traefik_1 | time="2021-10-15T23:16:28Z" level=info msg="Starting provider *docker.Provider {"endpoint":"unix:///var/run/docker.sock","defaultRule":"Host({{ normalize .Name }})","exposedByDefault":true,"swarmModeRefreshSeconds":"15s"}"
traefik_1 | time="2021-10-15T23:16:28Z" level=info msg="Starting provider *acme.ChallengeTLSALPN {"Timeout":4000000000}"
traefik_1 | time="2021-10-15T23:16:28Z" level=info msg="Starting provider *acme.Provider {"email":"zeenmc@gmail.com","caServer":"https://acme-v02.api.letsencrypt.org/directory","storage":"acme.json","keyType":"RSA4096","httpChallenge":{"entryPoint":"web"},"ResolverName":"myresolver","store":{},"TLSChallengeProvider":{"Timeout":4000000000},"HTTPChallengeProvider":{}}"
traefik_1 | time="2021-10-15T23:16:28Z" level=info msg="Testing certificate renew..." providerName=myresolver.acme
traefik_1 | time="2021-10-15T23:16:28Z" level=debug msg="No default certificate, generating one" tlsStoreName=default
traefik_1 | time="2021-10-15T23:16:28Z" level=debug msg="Configuration received from provider myresolver.acme: {"http":{},"tls":{}}" providerName=myresolver.acme
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Provider connection established with docker 20.10.9 (API 1.41)" providerName=docker
traefik_1 | time="2021-10-15T23:16:29Z" level=error msg="field not found, node: https" providerName=docker container=web-traefik-3775819573a2060b89b33a04b97bf1a1aca26079d07dc50c7e700c3959462203
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Configuration received from provider docker: {"http":{"routers":{"traefik-traefik":{"service":"traefik-traefik","rule":"Host(traefik-traefik)"}},"services":{"traefik-traefik":{"loadBalancer":{"servers":[{"url":"http://172.18.0.3:80"}],"passHostHeader":true}}}},"tcp":{},"udp":{}}" providerName=docker
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Added outgoing tracing middleware acme-http@internal" middlewareType=TracingForwarder entryPointName=web routerName=acme-http@internal middlewareName=tracing
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Creating middleware" entryPointName=web middlewareName=traefik-internal-recovery middlewareType=Recovery
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Added outgoing tracing middleware api@internal" routerName=api@internal middlewareName=tracing middlewareType=TracingForwarder entryPointName=traefik
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Added outgoing tracing middleware dashboard@internal" entryPointName=traefik routerName=dashboard@internal middlewareType=TracingForwarder middlewareName=tracing
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Creating middleware" middlewareType=StripPrefix entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_stripprefix@internal
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Adding tracing to middleware" routerName=dashboard@internal middlewareName=dashboard_stripprefix@internal entryPointName=traefik
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Creating middleware" middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex routerName=dashboard@internal entryPointName=traefik
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Setting up redirection from ^(http:\/\/(\[[\w:.]+\]|[\w\.
-]+)(:\d+)?)\/$ to ${1}/dashboard/" middlewareType=RedirectRegex routerName=dashboard@internal entryPointName=traefik middlewareName=dashboard_redirect@internal
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Adding tracing to middleware" middlewareName=dashboard_redirect@internal entryPointName=traefik routerName=dashboard@internal
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Creating middleware" entryPointName=traefik middlewareName=traefik-internal-recovery middlewareType=Recovery
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="No default certificate, generating one" tlsStoreName=default
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Added outgoing tracing middleware acme-http@internal" middlewareType=TracingForwarder entryPointName=web routerName=acme-http@internal middlewareName=tracing
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Creating middleware" entryPointName=web middlewareName=traefik-internal-recovery middlewareType=Recovery
web_1 | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
web_1 | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
web_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
web_1 | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
web_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
web_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
web_1 | /docker-entrypoint.sh: Configuration complete; ready for start up
web_1 | 2021/10/15 23:16:27 [notice] 1#1: using the "epoll" event method
web_1 | 2021/10/15 23:16:27 [notice] 1#1: nginx/1.21.3
web_1 | 2021/10/15 23:16:27 [notice] 1#1: built by gcc 8.3.0 (Debian 8.3.0-6)
web_1 | 2021/10/15 23:16:27 [notice] 1#1: OS: Linux 5.11.0-18-generic
web_1 | 2021/10/15 23:16:27 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
web_1 | 2021/10/15 23:16:27 [notice] 1#1: start worker processes
web_1 | 2021/10/15 23:16:27 [notice] 1#1: start worker process 22
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Added outgoing tracing middleware api@internal" routerName=api@internal entryPointName=traefik middlewareName=tracing middlewareType=TracingForwarder
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Added outgoing tracing middleware dashboard@internal" middlewareName=tracing middlewareType=TracingForwarder entryPointName=traefik routerName=dashboard@internal
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Creating middleware" middlewareName=dashboard_stripprefix@internal middlewareType=StripPrefix entryPointName=traefik routerName=dashboard@internal
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Adding tracing to middleware" middlewareName=dashboard_stripprefix@internal entryPointName=traefik routerName=dashboard@internal
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Creating middleware" routerName=dashboard@internal middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex entryPointName=traefik
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Setting up redirection from ^(http:\/\/(\[[\w:.]+\]|[\w\.-]+)(:\d+)?)\/$ to ${1}/dashboard/" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Adding tracing to middleware" routerName=dashboard@internal middlewareName=dashboard_redirect@internal entryPointName=traefik
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="Creating middleware" middlewareType=Recovery entryPointName=traefik middlewareName=traefik-internal-recovery
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [web websecure]" routerName=traefik-traefik
traefik_1 | time="2021-10-15T23:16:29Z" level=debug msg="No default certificate, generating one" tlsStoreName=default
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Creating middleware" entryPointName=web routerName=traefik-traefik@docker serviceName=traefik-traefik middlewareName=pipelining middlewareType=Pipelining
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Creating load-balancer" routerName=traefik-traefik@docker serviceName=traefik-traefik entryPointName=web
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Creating server 0 http://172.18.0.3:80" entryPointName=web routerName=traefik-traefik@docker serviceName=traefik-traefik serverName=0
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="child http://172.18.0.3:80 now UP"
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Propagating new UP status"
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Added outgoing tracing middleware traefik-traefik" middlewareName=tracing entryPointName=web routerName=traefik-traefik@docker middlewareType=TracingForwarder
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Added outgoing tracing middleware acme-http@internal" routerName=acme-http@internal entryPointName=web middlewareType=TracingForwarder middlewareName=tracing
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Creating middleware" entryPointName=web middlewareName=traefik-internal-recovery middlewareType=Recovery
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Creating middleware" entryPointName=websecure middlewareName=traefik-internal-recovery middlewareType=Recovery
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Added outgoing tracing middleware api@internal" middlewareType=TracingForwarder entryPointName=traefik routerName=api@internal middlewareName=tracing
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Added outgoing tracing middleware dashboard@internal" routerName=dashboard@internal middlewareName=tracing middlewareType=TracingForwarder entryPointName=traefik
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Creating middleware" middlewareName=dashboard_stripprefix@internal entryPointName=traefik routerName=dashboard@internal middlewareType=StripPrefix
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Adding tracing to middleware" middlewareName=dashboard_stripprefix@internal entryPointName=traefik routerName=dashboard@internal
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Creating middleware" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Setting up redirection from ^(http:\/\/(\[[\w:.]+\]|[\w\.
-]+)(:\d+)?)\/$ to ${1}/dashboard/" routerName=dashboard@internal middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex entryPointName=traefik
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Adding tracing to middleware" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_redirect@internal
traefik_1 | time="2021-10-15T23:16:30Z" level=debug msg="Creating middleware" entryPointName=traefik middlewareName=traefik-internal-recovery middlewareType=Recovery
traefik_1 | time="2021-10-15T23:16:48Z" level=debug msg="Serving default certificate for request: "ram.brote.dev""
traefik_1 | time="2021-10-15T23:16:49Z" level=debug msg="Serving default certificate for request: "ram.brokte.dev""
traefik_1 | time="2021-10-15T23:17:00Z" level=debug msg="Serving default certificate for request: "ram.brote.dev""
root@docker-traefik:~/traefik#

Kindly assist.

Try without the watch: false

@zeenmc,

in your traefik.yaml you define an entrypoint called 'websecure', but in the docker-compose.yml your nginx container uses an entrypoint called 'secureweb'.

1 Like

Hello Wiooimatic,

Good catch, I fixed same night, I found what was issue. I forgot to reply on my question.
I forgot because I found another problem. My services working fine now, but every time when I create new service I nee to restart traefik (Docker-compose up -d ) do you know why is like that, and is there any other way how to configure Traefik to recognize new service without restart ?
Thank you Team in advance :).

Hi Zeenmc,

normally traefik2 should detect the new services automatically. This is one of the big advantages of traefik.
As cakiwi said, try without the "watch: false" in the traefik.yaml.

Regards,
Wolfgang

Thank you both.
I changed config for watch from false to true,and now is working. It was true before, just I change many configs before I figured typo error in traefk.yml.

Just last question traefik-traefik service, and traefik-traefik@docker are normal ? it is mandatory like to see them in routers and services ?

Thank you in advance.

1 Like

I don't know your complete configuration, but I guess traefik-traefik is the dashboard.

This will be from the default rule and exposedByDefault:

https://doc.traefik.io/traefik/providers/docker/#defaultrule

Team,

You did a great job as you assisted me A LOT :).
I have opened another topic, if you are able to assist me.
Thank you in advance :slight_smile:

Thank you guys :).