Jens Knipper

Testing Regular Expressions in Traefik

May 17, 2020 | 1 Minute Read

T esting regular expressions for application configuration is always a pain as every programming language has a slightly different implementation. This results in expressions giving different results for different applications.

Sometimes it is not possible or just too much effort to make the Traefik configuration work locally. Testing on a production environment can be dangerous thus should not be an option. In these cases testing small parts of the configuration is essential. Regular expressions are one example where you can save a lot of time when testing outside of traefik.

The Reverse Proxy Traefik is written in Go. That is why Traefik uses the regex implementation of Go. Be aware that Go also introduces a slightly different syntax for its regular expressions.

Now that we know which expressions to test it becomes easy to find a tester for Go regex. I personally prefer regex101.com. The site lets you chose between different regex implementations. Make sure to pick the Golang flavor. It also makes it easy to test your possible input and displays information about matches, which comes in handy when testing redirects.