I am currently migrating from NginxProxyManager to Traefik and i am facing a problem
Here my dynamic configuration
http:
## EXTERNAL ROUTING ##
routers:
example:
entryPoints:
- https
rule: 'Host(`example.com`)'
service: example
tools:
entryPoints:
- https
rule: 'Host(`tools.example.com`)'
service: tools
## SERVICES ##
services:
example:
loadBalancer:
servers:
- url: http://192.168.2.4:80
tools:
loadBalancer:
servers:
- url: http://192.168.2.4/tools/
## MIDDLEWARES ##
middlewares:
# Security headers
securityHeaders:
headers:
customResponseHeaders:
X-Robots-Tag: "none,noarchive,nosnippet,notranslate,noimageindex"
X-Forwarded-Proto: "https"
server: ""
customRequestHeaders:
X-Forwarded-Proto: "https"
sslProxyHeaders:
X-Forwarded-Proto: "https"
referrerPolicy: "same-origin"
hostsProxyHeaders:
- "X-Forwarded-Host"
contentTypeNosniff: true
browserXssFilter: true
forceSTSHeader: true
stsIncludeSubdomains: true
stsSeconds: 63072000
stsPreload: true
The example router is working as expected, bot the tools router is not. Both point to the same webserver but the second one should reflext the "/tools" subdirectory as its own subdomain.
Is there an easy way to achive this?
Also note that i have like 30 entries similar to this.
I appreciate any form of help.
What’s not working?
What does Traefik debug log and access log tell you?
Did you have the same configuration with nginx before (tools. -> /tools)?
@bluepuma77
the tools.example.com route is sending me to the same endpoint as the example.com route
On the Nginx Proxy i had the same rule setup and there it was working (so tools.exmaple.com showed me the same result as if i would browse http://192.168.2.4/tools/ )
This is what the access.log shows (filtered all unrelated stuff from other services that made calls)
XXX.XXX.XXX.XXX - - [17/Feb/2023:23:52:55 +0000] "GET / HTTP/2.0" 200 1082 "-" "-" 75 "tools@file" "http://192.168.2.4/tools/" 53ms
XXX.XXX.XXX.XXX - - [17/Feb/2023:23:52:56 +0000] "GET / HTTP/2.0" 404 19 "-" "-" 76 "-" "-" 0ms
Traefik container debug log
time="2023-02-17T15:47:55-08:00" level=debug msg="Creating middleware" routerName=tools@file serviceName=tools middlewareName=pipelining middlewareType=Pipelining entryPointName=https
time="2023-02-17T15:47:55-08:00" level=debug msg="Creating load-balancer" routerName=tools@file serviceName=tools entryPointName=https
time="2023-02-17T15:47:55-08:00" level=debug msg="Creating server 0 http://192.168.2.4/tools/" routerName=tools@file serviceName=tools serverName=0 entryPointName=https
time="2023-02-17T15:47:55-08:00" level=debug msg="child http://192.168.2.4/tools/ now UP"
time="2023-02-17T15:47:55-08:00" level=debug msg="Added outgoing tracing middleware tools" middlewareType=TracingForwarder middlewareName=tracing entryPointName=https routerName=tools@file
time="2023-02-17T15:47:55-08:00" level=debug msg="Creating middleware" middlewareType=Headers routerName=tools@file entryPointName=https middlewareName=securityHeaders@file
time="2023-02-17T15:47:55-08:00" level=debug msg="Setting up secureHeaders from {map[X-Forwarded-Proto:https] map[X-Forwarded-Proto:https X-Robots-Tag:none,noarchive,nosnippet,notranslate,noimageindex server:] false [] [] [] [] [] 0 false [] [X-Forwarded-Host] false false map[X-Forwarded-Proto:https] false 63072000 true true true false true true same-origin false}" middlewareType=Headers routerName=tools@file entryPointName=https middlewareName=securityHeaders@file
time="2023-02-17T15:47:55-08:00" level=debug msg="Setting up customHeaders/Cors from {map[X-Forwarded-Proto:https] map[X-Forwarded-Proto:https X-Robots-Tag:none,noarchive,nosnippet,notranslate,noimageindex server:] false [] [] [] [] [] 0 false [] [X-Forwarded-Host] false false map[X-Forwarded-Proto:https] false 63072000 true true true false true true same-origin false}" middlewareType=Headers routerName=tools@file entryPointName=https middlewareName=securityHeaders@file
time="2023-02-17T15:47:55-08:00" level=debug msg="Adding tracing to middleware" middlewareName=securityHeaders@file entryPointName=https routerName=tools@file
time="2023-02-17T15:47:55-08:00" level=debug msg="Adding route for tools.example.com with TLS options default" entryPointName=https
Thinking about it, the target service URL is probably just used for scheme://domain:port
. Try creating and assigning an addprefix middleware.
Thanks.
after changing my dynamic configuration to this (including the add-prefix middleware) it finally works. I also can remove all unnessaccary services (as they would be duplicates) which does not alter the workflow for new entrys that much.
http:
## EXTERNAL ROUTING ##
routers:
tools:
entryPoints:
- https
rule: 'Host(`tools.example.com`)'
service: example
middlewares:
- "example-tools"
example:
entryPoints:
- https
rule: 'Host(`example.com`)'
service: example
## SERVICES ##
services:
example:
loadBalancer:
servers:
- url: http://192.168.2.4:80
## MIDDLEWARES ##
middlewares:
example-tools:
addprefix:
prefix: "/tools"
# Security headers
securityHeaders:
headers:
customResponseHeaders:
X-Robots-Tag: "none,noarchive,nosnippet,notranslate,noimageindex"
X-Forwarded-Proto: "https"
server: ""
customRequestHeaders:
X-Forwarded-Proto: "https"
sslProxyHeaders:
X-Forwarded-Proto: "https"
referrerPolicy: "same-origin"
hostsProxyHeaders:
- "X-Forwarded-Host"
contentTypeNosniff: true
browserXssFilter: true
forceSTSHeader: true
stsIncludeSubdomains: true
stsSeconds: 63072000
stsPreload: true
system
Closed
February 21, 2023, 10:09am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.