Nginx change request_uri in order to proxy redirect to the right url

I want to be able to redirect several requests to different containers running in the same machine. To do this im trying to use nginx. Conf file im using at the moment.

server{         listen 80;         location /foo{                 proxy_pass "http://1.1.0.2:10";                 proxy_set_header X-Real-IP $  remote_addr;                 proxy_set_header X-Forwarded-For   $  proxy_add_x_forwarded_for;         }           location /bar{                 proxy_pass "http://1.1.0.3:10";                 proxy_set_header X-Real-IP $  remote_addr;                 proxy_set_header X-Forwarded-For   $  proxy_add_x_forwarded_for;         } } 

My problem is that the /foo and /bar are just like tags in order to know to which container to redirect. By doing this way the /foo and /bar are being sent as a $ request_uri that will result in an error. I want to filter them or change them to / alone.

I tried some rewrites but it seems im not getting lucky.