Currently, I have a regular webserver running and I want to run traefik behind it.
For some reason though, I always get a 404 (from traefik, not the webserver) when I try to access one of my containers running behind traefik trough my webserver. However, if I hit traefik up directly (i.e. port 2000), I can access those containers.
Any pointers to what I'm doing wrong would be greatly appreciated
/etc/traefik/traefik.yaml
accessLog:
format: json
fields:
headers:
defaultMode: keep
global:
checkNewVersion: true
sendAnonymousUsage: false
entryPoints:
web:
address: :80
forwardedHeaders:
insecure: true
api:
dashboard: true
providers:
docker:
exposedByDefault: false
network: traefik
traefik/docker-compose.yml
networks:
traefik:
external: true
services:
traefik:
container_name: traefik
image: traefik:v2.8
restart: always
labels:
traefik.enable: true
traefik.http.routers.traefik-dashboard.entrypoints: web
traefik.http.routers.traefik-dashboard.rule: Host(`traefik.domain.de`)
traefik.http.routers.traefik-dashboard.service: api@internal
traefik.http.routers.traefik-dashboard.middlewares: traefik-dashboard_auth
traefik.http.middlewares.traefik-dashboard_auth.basicauth.users: admin:bcrypt_hash
networks:
traefik:
ipv4_address: 172.20.255.254
ports:
- 2000:80
volumes:
- /etc/traefik:/etc/traefik
- /var/run/docker.sock:/var/run/docker.sock:ro
some-project/docker-compose.yml
name: some-prefix
networks:
main:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.28.0.32/28
traefik:
external: true
services:
some-name:
image: some-image:latest
user: "${UID}:${GID}"
restart: unless-stopped
depends_on:
- mysql
networks:
main:
ipv4_address: 172.28.0.46
traefik:
volumes:
- ./assets:/assets:ro
labels:
traefik.enable: true
traefik.http.routers.ji.entrypoints: web
traefik.http.routers.ji.rule: Host(`intra.domain2.de`)
traefik.http.services.ji.loadbalancer.server.port: 8080
env_file: .env
environment:
# ...
mysql:
# ...
Excerpt from an access log for a 404:
{
"ClientAddr": "172.20.0.1:57772",
"ClientHost": "ip1",
"ClientPort": "57772",
"ClientUsername": "-",
"DownstreamContentSize": 19,
"DownstreamStatus": 404,
"Duration": 43366,
"OriginContentSize": 19,
"OriginDuration": 17335,
"OriginStatus": 404,
"Overhead": 26031,
"RequestAddr": "localhost:2000",
"RequestContentSize": 0,
"RequestCount": 1,
"RequestHost": "localhost",
"RequestMethod": "GET",
"RequestPath": "/",
"RequestPort": "2000",
"RequestProtocol": "HTTP/1.1",
"RequestScheme": "http",
"RetryAttempts": 0,
"StartLocal": "2023-02-13T09:47:53.571138751Z",
"StartUTC": "2023-02-13T09:47:53.571138751Z",
"downstream_Content-Type": "text/plain; charset=utf-8",
"downstream_X-Content-Type-Options": "nosniff",
"entryPointName": "web",
"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/avif,image/webp,image/apng,*/*;q=0.8",
"request_Accept-Encoding": "gzip, deflate",
"request_Accept-Language": "en-GB,en;q=0.5",
"request_Cache-Control": "max-age=0",
"request_Connection": "close",
"request_Cookie": "flash=MTY3NjI4MTQ1MnxEdi1CQkFFQ180SUFBUkFCRUFBQU12LUNBQUVHYzNSeWFXNW5EQW9BQ0hKbFpHbHlaV04wRGx0ZGFXNTBaWEptWVdObElIdDlfNE1DQVFMX2hBQUJFQUFBTmYtRU1nQUVCbk4wY21sdVp3d0RBQUV2Qm5OMGNtbHVad3dEQUFFdkJuTjBjbWx1Wnd3REFBRXZCbk4wY21sdVp3d0RBQUV2fK8SNx2C18YW6E2RcHlwstwXqF4NGDy6MJwaTH0OmRjD",
"request_Sec-Gpc": "1",
"request_Upgrade-Insecure-Requests": "1",
"request_User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36",
"request_X-Forwarded-For": "ip1",
"request_X-Forwarded-Host": "intra.domain2.de",
"request_X-Forwarded-Port": "2000",
"request_X-Forwarded-Proto": "http",
"request_X-Forwarded-Server": "fb4130d20b08",
"request_X-Real-Ip": "172.20.0.1",
"time": "2023-02-13T09:47:53Z"
}