From 5d716f01493d1085d579be52bbd5aed5b750fe03 Mon Sep 17 00:00:00 2001 From: Jack Morgan Date: Wed, 6 Oct 2021 22:36:11 +1300 Subject: [PATCH] Mention escaping escape characters in YAML for regex usage --- docs/content/middlewares/http/forwardauth.md | 6 ++++++ docs/content/middlewares/http/headers.md | 4 +++- docs/content/middlewares/http/redirectregex.md | 10 ++++++---- docs/content/middlewares/http/replacepathregex.md | 4 +++- docs/content/middlewares/http/stripprefixregex.md | 10 ++++++---- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/docs/content/middlewares/http/forwardauth.md b/docs/content/middlewares/http/forwardauth.md index 3a453ff6f..f56fd320f 100644 --- a/docs/content/middlewares/http/forwardauth.md +++ b/docs/content/middlewares/http/forwardauth.md @@ -284,6 +284,12 @@ http: authResponseHeadersRegex = "^X-" ``` +!!! tip + + Regular expressions and replacements can be tested using online tools such as [Go Playground](https://play.golang.org/p/mWU9p-wk2ru) or the [Regex101](https://regex101.com/r/58sIgx/2). + + When defining a regular expression within YAML, any escaped character needs to be escaped twice: `example\.com` needs to be written as `example\\.com`. + ### `authRequestHeaders` The `authRequestHeaders` option is the list of the headers to copy from the request to the authentication server. diff --git a/docs/content/middlewares/http/headers.md b/docs/content/middlewares/http/headers.md index a728ced1c..b8dd29b5f 100644 --- a/docs/content/middlewares/http/headers.md +++ b/docs/content/middlewares/http/headers.md @@ -333,7 +333,9 @@ It allows all origins that contain any match of a regular expression in the `acc !!! tip - Regular expressions can be tested using online tools such as [Go Playground](https://play.golang.org/p/mWU9p-wk2ru) or the [Regex101](https://regex101.com/r/58sIgx/2). + Regular expressions and replacements can be tested using online tools such as [Go Playground](https://play.golang.org/p/mWU9p-wk2ru) or the [Regex101](https://regex101.com/r/58sIgx/2). + + When defining a regular expression within YAML, any escaped character needs to be escaped twice: `example\.com` needs to be written as `example\\.com`. ### `accessControlExposeHeaders` diff --git a/docs/content/middlewares/http/redirectregex.md b/docs/content/middlewares/http/redirectregex.md index ecf3566b7..fce7d5f07 100644 --- a/docs/content/middlewares/http/redirectregex.md +++ b/docs/content/middlewares/http/redirectregex.md @@ -73,10 +73,6 @@ http: ## Configuration Options -!!! tip - - Regular expressions and replacements can be tested using online tools such as [Go Playground](https://play.golang.org/p/mWU9p-wk2ru) or the [Regex101](https://regex101.com/r/58sIgx/2). - ### `permanent` Set the `permanent` option to `true` to apply a permanent redirection. @@ -85,6 +81,12 @@ Set the `permanent` option to `true` to apply a permanent redirection. The `regex` option is the regular expression to match and capture elements from the request URL. +!!! tip + + Regular expressions and replacements can be tested using online tools such as [Go Playground](https://play.golang.org/p/mWU9p-wk2ru) or the [Regex101](https://regex101.com/r/58sIgx/2). + + When defining a regular expression within YAML, any escaped character needs to be escaped twice: `example\.com` needs to be written as `example\\.com`. + ### `replacement` The `replacement` option defines how to modify the URL to have the new target URL. diff --git a/docs/content/middlewares/http/replacepathregex.md b/docs/content/middlewares/http/replacepathregex.md index 329ceedd0..9862a308b 100644 --- a/docs/content/middlewares/http/replacepathregex.md +++ b/docs/content/middlewares/http/replacepathregex.md @@ -79,7 +79,9 @@ The ReplacePathRegex middleware will: !!! tip - Regular expressions and replacements can be tested using online tools such as [Go Playground](https://play.golang.org/p/mWU9p-wk2ru) or [Regex101](https://regex101.com/r/58sIgx/2). + Regular expressions and replacements can be tested using online tools such as [Go Playground](https://play.golang.org/p/mWU9p-wk2ru) or the [Regex101](https://regex101.com/r/58sIgx/2). + + When defining a regular expression within YAML, any escaped character needs to be escaped twice: `example\.com` needs to be written as `example\\.com`. ### `regex` diff --git a/docs/content/middlewares/http/stripprefixregex.md b/docs/content/middlewares/http/stripprefixregex.md index 768a05994..74bfebba9 100644 --- a/docs/content/middlewares/http/stripprefixregex.md +++ b/docs/content/middlewares/http/stripprefixregex.md @@ -67,11 +67,13 @@ The StripPrefixRegex middleware strips the matching path prefix and stores it in The `regex` option is the regular expression to match the path prefix from the request URL. -!!! tip - - Regular expressions can be tested using online tools such as [Go Playground](https://play.golang.org/p/mWU9p-wk2ru) or the [Regex101](https://regex101.com/r/58sIgx/2). - For instance, `/products` also matches `/products/shoes` and `/products/shirts`. If your backend is serving assets (e.g., images or JavaScript files), it can use the `X-Forwarded-Prefix` header to properly construct relative URLs. Using the previous example, the backend should return `/products/shoes/image.png` (and not `/images.png`, which Traefik would likely not be able to associate with the same backend). + +!!! tip + + Regular expressions and replacements can be tested using online tools such as [Go Playground](https://play.golang.org/p/mWU9p-wk2ru) or the [Regex101](https://regex101.com/r/58sIgx/2). + + When defining a regular expression within YAML, any escaped character needs to be escaped twice: `example\.com` needs to be written as `example\\.com`.