# Help trying to understand a rewrite rule

**URL:** <https://www.ruby-forum.com/t/help-trying-to-understand-a-rewrite-rule/243743>\
**Category:** NGINX\
**Created:** [December 29, 2015, 5:29pm UTC](https://www.ruby-forum.com/t/help-trying-to-understand-a-rewrite-rule/243743 "2015-12-29T17:29:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [December 29, 2015, 5:29pm UTC](https://www.ruby-forum.com/t/help-trying-to-understand-a-rewrite-rule/243743/1 "2015-12-29T17:29:32Z")

</div>

Hi everyone,

I have 2 graphites running with uWSGI in two separated servers, both  
listening in the port 3031. In a third server I also have an nginx  
installed . In that nginx, I’ve this configuration:

upstream graphite {  
server 10.0.2.22:3031;  
}  
upstream graphite2 {  
server 10.0.2.21:3031;  
}

server {  
listen 80;

```
    location / {
            include uwsgi_params;
            uwsgi_pass graphite;
    }

    location /graphite02 {
            rewrite /graphite02/(.+) /$1 break;
            include uwsgi_params;
            uwsgi_pass graphite2;
    }

```

}

My intention is:

- Every request http://nginx\_ip/ goes to the first graphite
- Every request http://nginx\_ip/graphite02/ goes to the second one BUT  
as /  
not /graphite02

My configuration doesn’t do what I need, instead every request  
http://nginx\_ip/graphite02/ goes to the FIRST graphite as /

Also, I’ve tried modifying this:

…  
location /graphite02 {  
uwsgo\_param PATH\_INFO /;  
include uwsgi\_params;  
uwsgi\_pass graphite2;  
}  
…

With no success. Can you help me to understand where is my problem?  
Perhaps  
I misunderstood completely the way that rewrites works.

Thanks!
