From 726fbc24636a496e3d84c643836ea67a022f94b2 Mon Sep 17 00:00:00 2001 From: Zenara Daley Date: Thu, 4 Oct 2018 16:32:19 -0400 Subject: [PATCH] add example to docs for dynamic rewrites --- docs/examples/rewrite/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/examples/rewrite/README.md b/docs/examples/rewrite/README.md index 3ad2593bbe..c8ef4c06af 100644 --- a/docs/examples/rewrite/README.md +++ b/docs/examples/rewrite/README.md @@ -93,6 +93,33 @@ BODY: -no body in request- ``` +### Dynamic Rewrite Target + +Create an Ingress rule with a rewrite annotation: + +```console +$ echo " +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + annotations: + nginx.ingress.kubernetes.io/rewrite-target: /$1 + name: rewrite + namespace: default +spec: + rules: + - host: rewrite.bar.com + http: + paths: + - backend: + serviceName: http-svc + servicePort: 80 + path: /something/(.+) +" | kubectl create -f - +``` + +In this case a request to `rewrite.bar.com/something/new` will redirect to `rewrite.bar.com/new`. + ### App Root Create an Ingress rule with a app-root annotation: