title: Nginx - encoding (normalizing) part of URI
body: <p>I have nginx <code>location</code> directive which purpose is to "remove" localization prefix from the URI for the <code>proxy_pass</code> directive.</p>
  
  <p>For example, to make URI <a href="http://example.com/en/lalala" rel="noreferrer">http://example.com/en/lalala</a> use proxy_pass <a href="http://example.com/lalala" rel="noreferrer">http://example.com/lalala</a></p>
  
  <pre><code>location ~ '^/(?&lt;locale&gt;[\w]{2})(/(?&lt;rest&gt;.*))?$' {
          ...
          proxy_pass http://example/$rest;
          ...
  }
  </code></pre>
  
  <p>This way the <code>rest</code> variable will be decoded when passed to proxy_pass directeve. It seems to be an expected <a href="http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass" rel="noreferrer">behavior</a>.</p>
  
  <p>The problem is when my URI contains encoded space <code>%20</code> passed from client</p>
  
  <pre><code>http://example.com/lala%20lala
  </code></pre>
  
  <p>nginx decodes URI to</p>
  
  <pre><code>http://example.com/lala lala
  </code></pre>
  
  <p>I can see it in my error.log.</p>
  
  <p>The question is - is it possible do use encoded <code>rest</code> variable somehow as it is passed from client?
  If I am doing something completely wrong, please, suggest the right way.</p>
  
  <p>Thank you.</p>