title: Docker container routing
body: <p>I'm trying to use docker/docker-compose to implement a webserver where part of my pages are served by PHP, and part are served by Java. So, when I connect to <code>localhost/php-service</code>, i'd get routed to a container running a PHP server, and connecting to <code>localhost/java-service</code> would redirect me to the container running the Java webserver.</p>
  
  <p>My first approach to this, which might be wrong, was to have a separate container running apache and to use mod-rewrite to redirect me to the appropriate container. Before trying anything fancy I simply tried redirecting to my php server container using its ip:</p>
  
  <pre class="lang-htaccess prettyprint-override"><code>#.htaccess
  RewriteEngine on
  RewriteRule .* http://192.168.128.6/ # &lt;- IP address of container with webserver 
  </code></pre>
  
  <p>This isn't working, as my browser simply rewrites the url to "192.168.128.6" and then complains about not finding the IP. Apparently the rewrite engine just tells the browser to go somewhere else, it doesn't actually forward the request. I <em>could</em> assign a different port to each server and have the rewrite engine forward to the appropriate port, but i feel like there must be a more elegant way of solving this. I've been looking at using iptables but it also doesn't feel like the right tool for the job...</p>
  
  <p>Thanks in advance for any help.</p>