title: nginx location with and without trailing slash
body: <p>I would like to create a location which catches both <a href="http://example.com" rel="noreferrer">http://example.com</a> and <a href="http://example.com/" rel="noreferrer">http://example.com/</a> and another location which catches everything else. The first one will serve static html and the other one is for the api and other stuff. I've tried with this:</p>
  
  <pre><code>location ~ /?$ {
      root /var/www/prod/client/www;
  }
  
  location ~ /.+ {
      # https://stackoverflow.com/questions/21662940/nginx-proxy-pass-cannot-have-uri-part-in-location
      rewrite ^/(.*) /$1 break;
      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_connect_timeout       1s;
      proxy_send_timeout          30s;
      proxy_read_timeout          300s;
      send_timeout                300s;
  
      proxy_redirect off;
      proxy_pass http://backendPro;
  }
  </code></pre>
  
  <p>But does not work. I've tried with many options in first location, but when it matches first then second is not matching and vice-versa:</p>
  
  <pre><code>location / {
  location ~ \/?$ {
  location ~ ^/?$ {
  </code></pre>