title: How to forward SSH into GitLab Docker container based on requested domain
body: <p>I have server running Ubuntu 16.04 with Docker engine installed. </p>
  
  <p>In one container I'm running <a href="https://gitlab.com/" rel="nofollow noreferrer">GitLab</a> service (and of course many other containers with other stuff). Let's call it's Docker network address <code>GITLAB_IP</code>.</p>
  
  <p>I'm using <a href="https://github.com/jwilder/nginx-proxy" rel="nofollow noreferrer">nginx-proxy</a> for proxying HTTP requests from the outside based on <code>VIRTUAL_HOST</code> environment variable. </p>
  
  <p>DNS is set up so everything targeted at <code>*.mydomain.com</code> goes to <code>mydomain.com</code> and is resolved on the same host.</p>
  
  <p>Requests going to <code>mydomain.com</code> are served by my main nginx container, while requests going to <code>gitlab.mydomain.com</code> are served by my GitLab container.</p>
  
  <p>Everything works well on port 80 (and 443).</p>
  
  <p>Now I want to be able to use git over ssh. What I'm trying to achieve is that if I do </p>
  
  <p><code>&gt; ssh mydomain.com</code> </p>
  
  <p>I will end up in terminal of my host server. And if I do </p>
  
  <p><code>&gt; ssh gitlab.mydomain.com</code></p>
  
  <p>then I want to end up in terminal of GitLab container. </p>
  
  <p>I know I can map port 22 of the container on some unused port on the host, so I'm able to access the container by ssh-ing to eg. port 10022, but I prefer it clean and clear.</p>
  
  <p>Is there any way to make ssh server on host machine somehow act as an proxy when specific domain is detected?</p>