-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Path/PathPrefix rules #26
Conversation
- Adding support for rules that contain Path or PathPrefix by appending the path after the hostname if present. - Resolved regexReplaceAll group matching when finding service name.
Hi @Sammy1Am and thanks for the PR. Regarding the changes: Adding support for rules that contain Path or PathPrefix by appending the path after the hostname if present. Resolved regexReplaceAll group matching when finding service name Append trailing slash
|
For what it's worth, I agree. 😉 However Traefik does (for some reason) require a trailing slash at the end of Because I'm trying to keep my services under a single domain/cert, I'm using a path for the dashboard like this:
This works, but only if I put the trailing slash in the URL. Now, all that being said, Traefik seems to be the exception here. I'm not really aware of anything else that requires the slash, though so far none of my services complain about it either. 🤷♂️ I figured since 100% of people installing Traefik Home will also have Traefik installed that it might make sense to cater to its weirdness, but I'd be (almost) equally happy to stick with the more-expected no-slash links and have Traefik's dashboard just broken for me. I'd also maybe be in favor of some sort of flag (or if we can reliably detect when the service is Traefik, even a hard-coded Traefik exception to add a slash), since that would allow the Traefik dashboard to work with a Path rule but keep other services slash-free. This does add additional code/logic though, so it's a tradeoff. Happy to do the legwork and make whatever changes you think make sense though. Also, thanks for this project; as soon as I got Traefik setup I wanted some kind of home page, hoped one existed, and here it was! |
Actually, there might be a way to redirect/add the slash using middleware; maybe I'll look into that later today. That way Traefik Home could just do regular paths for all the normal services and Traefik could get its own extra config. |
Does it works if you change your rule to |
Well using Additional commit pushed to remove trailing slash. |
Perfect. |
Everything looks good on my side |
Done 😄 . Thanks for the quick response, it'll be nice to point my compose file back to the official package instead of my own. |
Rather than a separate sub-domain for each service, I'm using paths for each one (e.g.
my.domain.com/grafana
), so I added support for rules that include paths. As written it requires hosts and paths to use backticks (`
) instead of escaped quotes, but this seems to be the recommended practice anyway. It also will only select the first host or path defined, but that was already sort of the case. While I was in there I replaced the tworegexReplaceAll
lines with a single line that uses groups (go templates do it sort of weird, and it took me a while to figure it out).These changes are working fine for me on my setup, but I'm not doing anything crazy beyond Host and PathPrefix, so additional testing might be warranted if there are any weird edge cases.
Changes: