title: Configuring nginx for single page website with HTML5 push state URL's
body: <p>How can I configure nginx to redirect all URL's (not prepended with <code>/api</code> or some static resource eg. JS/images) to <code>index.html</code>? Reason is I am using HTML5 push state URL's with a single page application. Meaning content is changed whether AJAX or JS depending on the URL</p>
  
  <p>My current nginx config looks like: </p>
  
  <pre><code>server {
      listen 2000;
      server_name localhost;
  
      location / {
          root    /labs/Projects/Nodebook/public;
          index   index.html;
      }
  
      location /api/ {
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_set_header X-NginX-Proxy true;
  
          proxy_pass http://localhost:3000/;
          proxy_redirect off;
      }
  }
  </code></pre>