title: host containers in different subfolders of URL http://10.10.10.10/site-a and http://10.10.10.10/site-b
body: <p>I have a dedicated server on which I want to host different sites, each running in a separate docker container.
  I don't have a domain, so I want to access the server by IP address or dynDNS URL. Each site should be 
  available under a subfolder of my IPaddress / dyndns like so:</p>
  
  <pre><code>http://10.10.10.10/site-a --&gt; redirects to e.g. nginx running in container A
  
  http://10.10.10.10/site-b --&gt; redirects to e.g. appache running in container B
  </code></pre>
  
  <p>etc.</p>
  
  <p>I think I should use a reverse proxy for this. I found this one <a href="https://github.com/jwilder/nginx-proxy" rel="nofollow noreferrer">https://github.com/jwilder/nginx-proxy</a> which seems to be pretty easy in terms of 
  extendablility if I plan to add further container in future.
  However I always get a HTTP 503 Service Temporarily Unavailable if I try to access <a href="http://10.10.10.10/site-a" rel="nofollow noreferrer">http://10.10.10.10/site-a</a> or 
  <a href="http://10.10.10.10/site-a" rel="nofollow noreferrer">http://10.10.10.10/site-a</a> or <a href="http://10.10.10.10" rel="nofollow noreferrer">http://10.10.10.10</a> directly.</p>
  
  <p>I tried the whoami example as described on <a href="https://github.com/jwilder/nginx-proxy#docker-compose" rel="nofollow noreferrer">https://github.com/jwilder/nginx-proxy#docker-compose</a> 
  This works perfectly if I try 
      curl -H "Host: whoami.local" localhost</p>
  
  <p>I modified this docker-compose.yml example to fit my use-case:</p>
  
  <pre><code>    version: '2'
  
      services:
        nginx-proxy:
          image: jwilder/nginx-proxy
          ports:
            - "80:80"
          volumes:
            - /var/run/docker.sock:/tmp/docker.sock:ro
  
        site-a:
          image: nginx
          volumes:
            - /home/chris/docker/site-a:/usr/share/nginx/html
          environment:
            - VIRTUAL_HOST=site-a.local
  
        site-b:
          image: nginx
          volumes:
            - /home/chris/docker/site-b:/usr/share/nginx/html
          environment:
            - VIRTUAL_HOST=site-b.local
  </code></pre>
  
  <p>Site-a and site-b are just nginx containers hosting a static html file for testing purpose.</p>
  
  <p>Executing </p>
  
  <pre><code>curl -H "Host: site-a.local" http://10.10.10.10
  </code></pre>
  
  <p>returns the static html from site-a</p>
  
  <pre><code>curl -H "Host: site-b.local" http://my-dyn-dns.com
  </code></pre>
  
  <p>returns the static html from site-b</p>
  
  <p>But if I try to access any of these URLs with the browser I get the HTTP 503 again :-(</p>
  
  <p>the nginx.conf is untouched from the dockerhub image:</p>
  
  <pre><code>/etc/nginx# cat nginx.conf 
  
  user  nginx;
  worker_processes  auto;
  
  error_log  /var/log/nginx/error.log warn;
  pid        /var/run/nginx.pid;
  
  
  events {
      worker_connections  1024;
  }
  
  
  http {
      include       /etc/nginx/mime.types;
      default_type  application/octet-stream;
  
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
  
      access_log  /var/log/nginx/access.log  main;
  
      sendfile        on;
      #tcp_nopush     on;
  
      keepalive_timeout  65;
  
      #gzip  on;
  
      include /etc/nginx/conf.d/*.conf;
  }
  daemon off;
  </code></pre>