title: How to proxy subdomains to other servers with dokku?
body: <p>I want my dokku host to run the main nginx for my domain (let say <code>cooldok.ku</code>).</p>
  
  <p>On cooldok.ku for some reasons I have other Virtual Machines serving content. I want to expose this content on a subdomain (say <code>vm.cooldok.ku</code>, runs in a VM at 10.0.0.7 on the cooldok.ku host).</p>
  
  <p>I figured the involved methodology is called reverse-proxy.</p>
  
  <p>In an optimal world, there would be a dokku-only way to register and 'link'/proxy the subdomains. As an added bonus, the <code>cooldok.ku</code> host would do the ssl-stuff for https itself (like ssltunnel) so that I could leverage existing certificates and/or use the awesome letsencrypt on the same machine and secure applications in the VM that were not meant to be served via https.</p>
  
  <p>How can this scenario be realised with dokku? How difficult would it be to write a plugin doing that?</p>
  
  <p><strong>Update</strong></p>
  
  <p>So, basically dokku (0.8) comes equipped with exactly everything it would need. The question is, how much of what dokku wants to achieve (fire up those yummy docker containers) is in the way. To hack a setup which does what I want, following can be done:</p>
  
  <pre><code># create folder where we want it
  dokku apps:create vm
  </code></pre>
  
  <p>Now, these files have to be created/be present (vanilla 0.8 dokku installation)</p>
  
  <pre><code>#/home/dokku/vm/DOCKER_OPTIONS_DEPLOY
  --restart=on-failure:10
  
  #/home/dokku/vm/IP.web.1 
  10.0.0.7
  
  #/home/dokku/vm/PORT.web.1 
  80
  
  #/home/dokku/vm/URLS 
  # THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN - I did it nonetheless
  http://vm.cooldok.ku
  
  #/home/dokku/vm/VHOST 
  vm.cookdok.ku
  
  #/home/dokku/vm/nginx.conf
  # Just listing changes from another default app
  [...]
  proxy_pass  http://vm-host;
  [...]
  upstream vm-host {
  
    server 10.0.0.7:80;
  }
  </code></pre>
  
  <p>Afterwards, nginx needs a manual restart (or ... dokku can do something for us here)</p>
  
  <p>I am pretty sure that some of the (redundant) information can be left out, as dokku should puzzle the nginx.conf itself, for example.  I am not sure if this setup survives a reboot/nginx restart.  Also, on tests, letsencrypt would not let me install the certificates/rebuild the nginx configuration because it sees the app <code>vm</code> as not being deployed.</p>
  
  <p><strong>Update2</strong></p>
  
  <p>To overcome the "app not deployed" issue, it suffices to <code>touch /home/dokku/vm/CONTAINER</code>, but this gets messier and messier ...</p>