title: Nginx proxy setup
body: <p>Hey guys I have a trouble with nginx proxy.</p>
  
  <p>I want to setup it to redirect all requests to one external site (already have that).</p>
  
  <p>But except the request on domain hg.mydomain.com these request I want to redirect to localhost:4567 (sinatra app lives there)</p>
  
  <p>But that doesnt work</p>
  
  <pre><code>user www-data;
  worker_processes  1;
  
  error_log  /var/log/nginx/error.log;
  pid        /var/run/nginx.pid;
  
  events {
      worker_connections  1024;
      # multi_accept on;
  }
  
  http {
      include       /etc/nginx/mime.types;
  
      access_log  /var/log/nginx/access.log;
  
      sendfile        on;
      #tcp_nopush     on;
  
      #keepalive_timeout  0;
      keepalive_timeout  65;
      tcp_nodelay        on;
  
      gzip  on;
      gzip_disable "MSIE [1-6]\.(?!.*SV1)";
  
  
      server {
         listen       80;
         server_name  *.hg.mydomain.com;
  
         location / {
              proxy_pass http://127.0.0.1:4567/;
         }
      }
  
      server {
          listen 80;
  
          location / {
              proxy_pass http://sb.mydomain.com;
              proxy_set_header X-Real-IP  $remote_addr;
              proxy_set_header X-Forwarded-For $remote_addr;
              proxy_set_header X-Shoebox-Host $host;
         }
      }
  }
  </code></pre>