title: Multiple docker containers accessible by nginx reverse proxy
body: <p>I'd like to run multiple docker containers on one host VM which would be accessible through only one domain. I wanted to use request url to differentiate  between containers.
      To achieve this I'm trying to set nginx server as reverse proxy and run it in the container also listening on port 80.</p>
  
  <p>Let's say I have two containers running on port 3000 and 4000.
  The routing would be following: </p>
  
  <pre><code>docker-host.example.com/3000 -&gt; this will access container exposing port 3000
  docker-host.example.com/4000 -&gt; this will access container exposing port 4000
  </code></pre>
  
  <p>The thing is I'm currently stack even with trying to define static rule for such reverse proxy.
  It works fine without any location:</p>
  
  <pre><code>upstream application {
      server &lt;docker container&gt;:3000;
  }
  
  server {
          listen 80;
  
          location / {
              proxy_pass_header  Server;
              proxy_set_header   Host $http_host;
              proxy_redirect     off;
              proxy_set_header   X-Real-IP $remote_addr;
              proxy_set_header   X-Scheme $scheme;
              proxy_pass         http://application/;
          }
  }
  </code></pre>
  
  <p>But when I add port location and try to access it using localhost:{nginx port}/3000/</p>
  
  <pre><code>upstream application {
      server &lt;docker container&gt;:3000;
  }
  
  server {
          listen 80;
  
          location /3000/ {
              proxy_pass_header  Server;
              proxy_set_header   Host $http_host;
              proxy_redirect     off;
              proxy_set_header   X-Real-IP $remote_addr;
              proxy_set_header   X-Scheme $scheme;
              proxy_pass         http://application/3000/;
          }
  }
  </code></pre>
  
  <p>It seems that first resource (main html) is requested correctly, but any other depending resource (for example js or css needed for this site) is missing. 
  If I examine request for those resources I have in logs:</p>
  
  <pre><code>09:19:20 [error] 5#5: *1 open() "/etc/nginx/html/public/css/fonts.min.css" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /public/css/fonts.min.css HTTP/1.1", host: "localhost:8455", referrer:"http://localhost:8455/3000/"
  </code></pre>
  
  <p>So request url is <a href="http://localhost:8455/public/css/fonts.min.css" rel="noreferrer">http://localhost:8455/public/css/fonts.min.css</a></p>
  
  <p>Instead of <a href="http://localhost:8455/3000/public/css/fonts.min.css" rel="noreferrer">http://localhost:8455/3000/public/css/fonts.min.css</a></p>
  
  <p>Could I ask you for any suggestions ? Is this scenario possible ?</p>