title: node.js server to return /, static files from /public/ via nginx?
body: <p>i'm having a little issue with Rasmus Andersson awesome node.js EC2 template <a href="http://rsms.me/2011/03/23/ec2-wep-app-template.html" rel="noreferrer">http://rsms.me/2011/03/23/ec2-wep-app-template.html</a></p>
  
  <p>ok, the issue is</p>
  
  <p>i would like the root url <a href="http://www.mydomain.com/" rel="noreferrer">http://www.mydomain.com/</a> response to be delivered by the node.js server (which listens on port 3000)</p>
  
  <p>nginx should still deliver everything static from  /public/ (so nginx should look in /public/ first, if it's not there pass the request to node.js on port 3000)
  i.e.: </p>
  
  <ul>
  <li><a href="http://www.mydomain.com/favicon.ico" rel="noreferrer">http://www.mydomain.com/favicon.ico</a>
  should response with the file from
  /var/mydomain/public/favicon.ico  </li>
  <li><a href="http://www.mydomain.com/" rel="noreferrer">http://www.mydomain.com/</a> should be
  passed to node.js on port 3000</li>
  <li><a href="http://www.mydomain.com/contentpage.html" rel="noreferrer">http://www.mydomain.com/contentpage.html</a> should be passed on to node.js on port 3000</li>
  </ul>
  
  <p>this is my <code>/etc/nginx/sites-available/mydomain-http</code> config file. i know that i will have to rewrite the location / part, but i don't know what i should put in there.</p>
  
  <p>thx a lot</p>
  
  <pre><code>## Access over HTTP (but not HTTPS)
  server {
    listen        80;
    listen        [::]:80 default ipv6only=on;
    access_log    /var/log/nginx/access.log;
    location / {
      root        /var/mydomain/public;
      index       index.html;
      error_page  404 = @backend;
    }
    location @backend {
      proxy_pass          http://127.0.0.1:3000;
      proxy_set_header    X-Client-IP  $remote_addr;
    }
  }
  </code></pre>