github.com/nginxinc/kubernetes-ingress@v1.12.5/examples/rewrites/README.md (about)

     1  # Rewrites Support
     2  
     3  You can configure NGINX to rewrite the URI of a request before sending it to the application. For example, `/tea/green` can be rewritten to `/green`.
     4  
     5  ## Syntax
     6  
     7  To configure URI rewriting you need to add the **nginx.org/rewrites** annotation to your Ingress resource definition. The annotation syntax is as follows:
     8  ```
     9  nginx.org/rewrites: "serviceName=service1 rewrite=rewrite1[;serviceName=service2 rewrite=rewrite2;...]"
    10  ```
    11  
    12  ## Example
    13  
    14  In the following example we load balance two applications that require URI rewriting:
    15  ```yaml
    16  apiVersion: networking.k8s.io/v1beta1
    17  kind: Ingress
    18  metadata:
    19    name: cafe-ingress
    20    annotations:
    21      nginx.org/rewrites: "serviceName=tea-svc rewrite=/;serviceName=coffee-svc rewrite=/beans/"
    22  spec:
    23    rules:
    24    - host: cafe.example.com
    25      http:
    26        paths:
    27        - path: /tea/
    28          backend:
    29            serviceName: tea-svc
    30            servicePort: 80
    31        - path: /coffee/
    32          backend:
    33            serviceName: coffee-svc
    34            servicePort: 80
    35  ```
    36  
    37  Below are the examples of how the URI of requests to the *tea-svc* are rewritten (Note that the `/tea` requests are redirected to `/tea/`).
    38  * `/tea/` -> `/`
    39  * `/tea/abc` -> `/abc`
    40  
    41  Below are the examples of how the URI of requests to the *coffee-svc* are rewritten (Note that the `/coffee` requests are redirected to `/coffee/`).
    42  
    43  * `/coffee/` -> `/beans/`
    44  * `/coffee/abc` -> `/beans/abc`