title: nginx proxy_pass with url rewrite - preserve URL
body: <p>I am trying to rewrite url for another domain, main agenda is keep the user in same URL[<strong>dev.gworks.mobi</strong>].</p>
  
  <p><code>http://dev.gworks.mobi/openam/*  -&gt; http://frock.gworks.mobi:8080/openam/*</code></p>
  
  <pre><code>location /openam {
  
            proxy_pass http://frock.gworks.mobi:8080/;
            proxy_redirect     off;
            proxy_set_header Host $host;
  }
  </code></pre>
  
  <p>it partially works</p>
  
  <ol>
  <li><code>http://dev.gworks.mobi/openam/ -&gt; http://frock.gworks.mobi:8080/</code>  [it works]</li>
  <li><code>http://dev.gworks.mobi/openam/XUI/#login/ -&gt; http://frock.gworks.mobi:8080/openam/XUI/#login/</code>[it does not work] </li>
  </ol>
  
  <p>The reason is <code>http://dev.gworks.mobi/openam/XUI/#login/</code> proxy to <code>http://frock.gworks.mobi:8080//XUI/#login/</code> instead of <code>http://frock.gworks.mobi:8080/openam/XUI/#login/</code>. I'm trying rewrite URL but I'm not successful.</p>
  
  <blockquote>
    <p>rewrite ^/openam/(.*)$ /$1 last;</p>
  </blockquote>
  
  <p>can anyone help me to achieve my use case?</p>