title: Docker proxy with custom networks
body: <p>I'm setting up a Docker server which has to host multiple containers that need to be accessible through http (80). I have followed this <a href="http://tech.mybuilder.com/virtual-hosts-with-docker/" rel="nofollow noreferrer">tutorial</a> and the example works perfect for the simple situation. The proxy image used is <code>jwilder/nginx-proxy</code> which automates the creation of the Nginx configurations when containers are set up or teared down.</p>
  <p>The problem is that all the projects that will run on the Docker server use custom networks which breaks the proxy.</p>
  <h1>The working situation</h1>
  <p>The tutorial way works when the proxy <strong>and</strong> the web server runs on the default <code>bridge</code> network. Then the proxy does his work and redirects the traffic to the correct container.
  <a href="https://i.stack.imgur.com/R5Krf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R5Krf.jpg" alt="working situation" /></a></p>
  <h1>The NOT working situation</h1>
  <p>Most of the projects will be Laravel applications and consists out of a webserver, PHP FPM and a database. Communication between the containers is through two networks; server and database.</p>
  <p>This setup didn't work with the proxy container on the bridge network. So I created a new network on the Docker server named <strong>proxy</strong> (bridge) and placed the proxy and project's nginx containers in it. The proxy server now successfully changes to the configuration to include the project (ip address:port). But when I try to access the domain then I get the default Nginx welcome page. The page remains working when the project containers are shut down. The page stops working when the proxy container is stopped.
  The project is working fine when I access the domain with the containers port.
  <a href="https://i.stack.imgur.com/ChHQt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ChHQt.jpg" alt="not working situation" /></a></p>
  <h2>TL;DR;</h2>
  <p>The proxy is working fine when both containers (proxy + app) are on the bridge network. The proxy gives a default Nginx Welcome page when the containers are in a custom network (see images).</p>
  <p>How can I make the proxy work?</p>
  <h2>What did I try?</h2>
  <ul>
  <li>Ping from proxy to project <strong>success</strong></li>
  <li>Used curl on proxy to project to check if webpage was working <strong>success</strong></li>
  <li>Checked proxy's Nginx config file for missing details. <strong>None</strong> <em>Project container's IP address plus port number are correct. File entry is identical to that of the example's case.</em></li>
  </ul>