traefik icon indicating copy to clipboard operation
traefik copied to clipboard

Feature request: support for an 'exclude' option on redirection (a.k.a negated regex)

Open ebreton opened this issue 9 years ago • 9 comments

I would like to redirect http to https based on a regex, and exclude one domain.

Something like:

[entryPoints.http.redirect]
    regex = "^http://(?!to.exclude.com).*$"

Unfortunately, (?!) is not supported in Go according to https://github.com/google/re2/wiki/Syntax.

Instead of waiting for this support, a feature like exclude could be added into the the traefik.toml config, that would negate regex

ebreton avatar Apr 01 '17 20:04 ebreton

@ebreton so your proposal is to add something like:

[entryPoints.http.redirect]
    regex = "^http://.*$"
    exclude = "^http://to.exclude.com.*$"

Right?

emilevauge avatar Apr 04 '17 09:04 emilevauge

yes :)

ebreton avatar Apr 04 '17 12:04 ebreton

@ebreton I think it's a good idea :) We would love to see a PR from you on this ;)

emilevauge avatar Apr 04 '17 21:04 emilevauge

Good. What is the best place to start with ? I am a pythoner, with some curiosity and a good reason to try go now. I guess starting with go is straighforward.

Do you have a cheatsheet to get up to speed with Traefik ?

For this particular feature, would you have a few recommendations for me ?

ebreton avatar Apr 05 '17 06:04 ebreton

@ebreton I guess the best advice is to learn by reading the code, especially the section you intend to modify.

If you have questions, don't hesitate to hop on to Slack. The #dev channel is to place to be to ask development-related questions.

timoreimann avatar Apr 25 '17 13:04 timoreimann

Any other workarounds or options to exclude single urls from redirection?

age-77 avatar Apr 19 '18 13:04 age-77

I can not believe this feature is not implemented.

TheNoim avatar Feb 16 '19 12:02 TheNoim

I'm struggling with this too. I'm doing http => https scheme redirection but this breaks the letsencrypt http challenge, thus I want to exclude .well-known/acme-challenge/.* from the redirection but can't seem to construct a regex to do this... Anyone got any workarounds?

badsyntax avatar Jul 19 '21 06:07 badsyntax

I'm struggling with this too. I'm doing http => https scheme redirection but this breaks the letsencrypt http challenge, thus I want to exclude .well-known/acme-challenge/.* from the redirection but can't seem to construct a regex to do this... Anyone got any workarounds?

did you find any solution for this? I also struggling with same

shwetakawale avatar Sep 06 '22 11:09 shwetakawale