title: Nginx (reverse proxy)+(web server) in the same domain
body: <p>I'm having problems setting nginx as a reverse proxy plus a web server, using the same hostname.</p>
  
  <p>Using example.com, I can navigate my website, and if I go to example.com/rproxy I can reverse proxy to another dummy website: external.com What I want to do is being able to fully navigate both websites in just one domain.</p>
  
  <p>But, I have problems when I use the links in the reverse proxy, as they don't get me where I want.</p>
  
  <p>If I configure example.com as a reverse proxy, using this config:</p>
  
  <pre><code> location / {
      proxy_set_header   X-Real-IP $remote_addr;
      proxy_pass external.com/;
      proxy_set_header X-Forwarded-Proto https;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
  </code></pre>
  
  <p>Then it works. If I click a link that takes me into external.com/config, then the URL I'm seeing in the browser is example.com/config, but I can see that it's the content available at external.com/config.</p>
  
  <p>All in all, I can navigate external.com fully.</p>
  
  <p>But if I use this:</p>
  
  <pre><code>location /rproxy {
      proxy_set_header   X-Real-IP $remote_addr;
      proxy_pass external.com/;
      proxy_set_header X-Forwarded-Proto https;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
  </code></pre>
  
  <p>There is no way to access the remote server folders. If I want to go to external.com/config, normally I click a config button and that takes me to example.com/rproxy/config, but the page is broken.</p>
  
  <p>I've read some docs and can't find a solution to this.</p>