# Transparent rewrite with nginx ingress

**URL:** <https://forums.suse.com/t/transparent-rewrite-with-nginx-ingress/12191>\
**Category:** SUSE Rancher Prime\
**Created:** [October 30, 2018, 1:09pm UTC](https://forums.suse.com/t/transparent-rewrite-with-nginx-ingress/12191 "2018-10-30T13:09:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![qdrop17](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/qdrop17/32/4573_2.png) [@qdrop17](https://forums.suse.com/u/qdrop17)\
**Post date:** [October 30, 2018, 1:09pm UTC](https://forums.suse.com/t/transparent-rewrite-with-nginx-ingress/12191/1 "2018-10-30T13:09:41Z")

</div>

Hello everyone.

I would like to do the following with the existing nginx ingress controller of Rancher 2 / Kubernetes:

```auto
server {
    listen 80;
    server_name $hostname localhost;

    auth_basic "Restricted";
    auth_basic_user_file pathtofile;

    location /kibana {
        rewrite ^/kibana/(.*)$ /$1 break;
        proxy_pass http://localhost:5601/;
    }
    location ~ ^/es(.*) {
        rewrite /es/(.*) /$1 break;
        proxy_pass http://localhost:9200;
    }   
}

```

Is it even possible to accomplish this in an easy way using annotations and ingress controller configuration? If not? How do you suggest to takle this problem?

Thank you!

---

<div class="post-metadata">

**Author:** ![Stonedge](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@Stonedge](https://forums.suse.com/u/Stonedge)\
**Post date:** [October 30, 2018, 1:44pm UTC](https://forums.suse.com/t/transparent-rewrite-with-nginx-ingress/12191/2 "2018-10-30T13:44:59Z")

</div>

Hi qdrop17,

I’m not an expert at all but here how I would do it using the rancher gui.

You should look at the following annotation of the nginx ingress:  
[nginx.ingress.kubernetes.io/rewrite-target:](http://nginx.ingress.kubernetes.io/rewrite-target:) /

using that annotation would enable you to trim out your selecting path (eg: /es/) before sending request to your selected service.

So create your load balancing rule in rancher gui (hostname, path, selector/workload) add the “[nginx.ingress.kubernetes.io/rewrite-target:](http://nginx.ingress.kubernetes.io/rewrite-target:) /” to the annotation… and you should be go to go

Stonedge
