title: Sinatra, Unicorn and Nginx - Proxy multiple Sinatra Apps
body: <p>I have multiple Sinatra apps on unicorn + nginx and I want to proxy the second Sinatra app to be on a <code>/app</code> path. </p>
  
  <pre><code>root
  root/app
  </code></pre>
  
  <p>Here is my nginx configuration file:</p>
  
  <pre><code>upstream root {
      # Path to Unicorn SOCK file, as defined previously
      server unix:/tmp/unicorn.root.com.sock fail_timeout=0;
  }
  
  upstream app {
      # Path to Unicorn SOCK file, as defined previously
      server unix:/tmp/unicorn.app.io.sock fail_timeout=0;
  }
  
  
  server {
      listen 80;
  
      # Set the server name, similar to Apache's settings
      server_name root.com www.root.com;
      # 301 redirect http://root.com$requesturi;
  
      # Application root, as defined previously
      root /var/www/root.com/public;
  
      try_files $uri/index.html $uri @root;
  
      location @root {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;
          proxy_pass http://root;
      }
  
      location /app {
          proxy_set_header   X-Real-IP $remote_addr;
          proxy_set_header   Host      $http_host;
          proxy_pass http://app;
      }
  
  
      error_page 500 502 503 504 /500.html;
      client_max_body_size 4G;
      keepalive_timeout 10;
  
      access_log  off;
  }
  </code></pre>
  
  <p>Using the configuration above I get a <code>404</code> from the <code>app</code> application.</p>
  
  <p>How can I achieve that? </p>