title: How to use a block for all non-root paths in nginx config?
body: <p>In a single page app behind nginx, I'd like all non-root paths to be handled by an upstream server:</p>
  
  <pre><code>upstream socket_nodes {
      server 127.0.0.1:5000;
  }
  server {
  
  listen 80;
  
  index index.html;
  
    location / {
      try_files $uri $uri/ /index.html;
    }
   location whaeverelse {
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_http_version 1.1;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $host;
          proxy_pass http://socket_nodes;
      }
  }
  </code></pre>
  
  <p>What I've tried was to list all the <code>whateverelse</code> paths to a line like this:</p>
  
  <pre><code>location /(api|user|profile|about|login|logout|register) {...
  </code></pre>
  
  <p>Apart from being hackish, that did not work. 
  I have also tried some wildcard regexps like this:</p>
  
  <pre><code>location  ~ ^/[0-9a-z] {
  </code></pre>
  
  <p>or even more excessive ones:</p>
  
  <pre><code>location  ~ ^/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W) {
  </code></pre>
  
  <p>with no success.<br>
  So I'm wondering what is the idiomatic way to do so?</p>