title: Reverse proxy Issue in Docker Containers with Nginx
body: <p>I have 2 containers, one running SITE A (port 8001) and other SITE B (port 8080). What I am trying to do is a reverse proxy from nginx. In nginx conf, I have a configuration for SITE A as </p>
  
  <pre><code>server {
         listen 8000;
         client_max_body_size 500M;
         server_name code;
  
         location / {
            proxy_pass   http://code:8001; #code is my container name in dockercompose
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         }
        #Static file location
        location /static/ {
               alias   /library/static_root/;
           if ($request_filename ~* ^.*?/([^/]*?)$)
              {
               set $filename $1;
              }
  
           if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$)
           {
           add_header Access-Control-Allow-Origin *;
           }
               expires 30d;
        }
  
  
  }
  </code></pre>
  
  <p>And my conf for SITE B is </p>
  
  <pre><code>server
      {
       listen 8000;
       server_name kolibri;
  
       location /learn/
       {
           proxy_pass http://kolibri:8080
           proxy_set_header   Host $host;
           proxy_set_header   X-Real-IP $remote_addr;
           proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header   X-Forwarded-Host $server_name;
       }
    }
  </code></pre>
  
  <p>But whenever I try to access the /learn uri it directs me to SITE A and error occurs </p>
  
  <pre><code>nginx_1      | 192.168.5.100 - - [07/Jan/2019:05:51:22 +0000] "GET /static      /learn_module/learn_module0.10.3.css HTTP/1.1" 404 143 "http://192.168.5.232/learn/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
  nginx_1      | 2019/01/07 05:51:22 [error] 9#9: *10 open() "/etc/nginx/html/static/learn_module/learn_module-0.10.3.js" failed (2: No such file or directory), client: 192.168.5.100, server: kolibri, request: "GET /static/learn_module/learn_module-0.10.3.js HTTP/1.1", host: "192.168.5.232", referrer: "http://192.168.5.232/learn/"
  nginx_1      | 192.168.5.100 - - [07/Jan/2019:05:51:22 +0000] "GET /static/learn_module/learn_module-0.10.3.js HTTP/1.1" 404 143 "http://192.168.5.232/learn/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
  </code></pre>
  
  <p>I have /static/ URI configured in SITE A so it might have redirected to SITE A but how can I make this call to SITE B itself. Hope this makes sense. Please help</p>