Container gets 404 despite nearly identical labels work on another container

Hi, first post here so if I miss anything just let me know.

I'm running a simple URL shortener backend I made which was earlier on a VPS and I moved it over to a container based solution with traefik in front, it works great.

Now my friend wanted the same setup, so I more or less duplicated that container setup, switched the router and service names in the labels (and what database it uses, but should be irrelevant here) and switched the router host rule to match his domain, but that second setup is getting a 404, where as my original one works without issue.

I feel like I have tried everything and am at a complete loss here, any help is greatly appreciated, below are the labels (only router name and domains switched, I have made sure this is not a case of a typo).

My container:

-- "traefik.enable=true"
-- "traefik.http.routers.myshortener.rule=Host(`example.com`)"
-- "traefik.http.routers.myshortener.entrypoints=websecure"
-- "traefik.http.routers.myshortener.service=myshortener"
-- "traefik.http.routers.myshortener.tls.certresolver=cl_resolver"
-- "traefik.http.services.myshortener.loadbalancer.server.port=4242"

And here is the setup for my friends one:

-- "traefik.enable=true"
-- "traefik.http.routers.friendsshortener.entrypoints=websecure"
-- "traefik.http.routers.friendsshortener.rule=Host(`short.example.com`)"
-- "traefik.http.routers.friendsshortener.service=friendsshortener"
-- "traefik.http.routers.friendsshortener.tls.certresolver=cl_resolver"
-- "traefik.http.services.friendsshortener.loadbalancer.server.port=4242"

As you can see the only real difference is that my friends one uses a subdomain and mine does not.

For reference I can see both of them show up in the traefik dashboard, both the routers and services, but in the access log if I go to my friends one it does not show his router and for mine it does. See below.

Mine:

[11/May/2021:09:02:36 +0000] "GET / HTTP/1.1" 200 31 "-" "-" 1112 "myshortener@docker" "http://172.18.0.5:4242" 1ms

My friends:

[11/May/2021:09:04:00 +0000] "GET / HTTP/1.1" 404 19 "-" "-" 1115 "-" "-" 0ms

My guess would be it has to do with the Host rule in some way? Since it seems like traefik does not want to route it properly and instead gives a 404, but I do not see what can be wrong with the rule, it is identical to many others I have that use subdomains and they all work fine.

It definitely not matching. That could be due to request using ip instead of hostname, docker provider not enabled, wrong entrypoint being accessed

Sure it is being hit on the right entrypoint?
Static configuration is the same as yours too?

To help debug I would recommend changing the accesslog to json format, the entryPointName,requestHost/requstAddr and requestScheme are included in this format.

Ah, the json format was indeed very helpful, thank you!

It was entering on the web entrypoint, not websecure due to different cloudflare settings.
(My domain had Full SSL and his had Flexible, so between cloudflare and server data was sent over http not https).

Many thanks for pointing me in the direction of the solution!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.