title: How to forward upstream from nginx to upstream server
body: <p>I am trying to reverse-proxy an ejabberd connection manager with nginx in docker.</p>
  
  <p>Following is my docker-compose file</p>
  
  <pre><code>version: '2'
  services:
    nginx:
      image: nginx
      ports:
        - "80:80"
        - "443:443"
      depends_on:
        - ejabberd
      links:
        - ejabberd
    ejabberd:
      image: ejabberd:16.04
      depends_on:
        - mysql
      ports:
        - "5280:5280"
      links:
        - mysql
    mysql:
      image: mysql:5.6
      ports:
        - "3306:3306"
  </code></pre>
  
  <p>The images <strong>nginx</strong>, <strong>ejabberd:16.04</strong> and <strong>mysql:5.6</strong> are available in my local docker.</p>
  
  <p>Following is my server config file which is included in the nginx.conf file</p>
  
  <pre><code>upstream ejabberd-server {
          server ejabberd:5280;
  }
  server {
      # regular silverstripe things here
  
      # location should match your JabberPage::BOSHUrl
      # with a leading slash
      listen 80;
      #server_name oops.hereim.co
  
      location /http-bind {
          # Local ejabberd with http-bind
          proxy_set_header X-Forwarded-Host $host;
          proxy_set_header X-Forwarded-Server $host;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://ejabberd-server;
      }
  
  }
  </code></pre>
  
  <p>But when I try to access the url <strong><em><a href="http://192.168.99.102/http-bind" rel="nofollow">http://192.168.99.102/http-bind</a></em></strong></p>
  
  <p>I get the error 404 not found.</p>
  
  <p>Am I missing something in the configuration above?</p>
  
  <p><strong>192.168.99.102</strong> is the IP of my docker machine.</p>
  
  <pre><code>docker-compose exec nginx ping ejabberd
  </code></pre>
  
  <p>The above command returns a reply.</p>
  
  <p>The upstream has to be setup to host ejabberd as nginx and ejabberd are not on the same ejabberd container.</p>
  
  <p>If you see the docker-compose.yml, the ejabberd and mysql connection works fine and I am able to connect to mysql from ejabberd. But there seems to be some missing piece while connection nginx to ejabberd.</p>