title: nginx not matching location (I think)
body: <p>I am migrating parse-server to a DigitalOcean Ubuntu droplet based on this documentation:</p>
  
  <p><a href="https://www.digitalocean.com/community/tutorials/how-to-migrate-a-parse-app-to-parse-server-on-ubuntu-14-04" rel="nofollow">https://www.digitalocean.com/community/tutorials/how-to-migrate-a-parse-app-to-parse-server-on-ubuntu-14-04</a></p>
  
  <p>I'm having an issue with nginx proxying (https) requests to parse-server. </p>
  
  <p>If I open port 1337 on my droplet and configure Parse http requests to go directly to parse-server (<a href="http://example.com:1337/parse" rel="nofollow">http://example.com:1337/parse</a>), this all works as expected.</p>
  
  <p>If I configure Parse http requests to go to <a href="https://example.com/parse" rel="nofollow">https://example.com/parse</a>, nginx fails to proxy the request to parse-server. </p>
  
  <p>nginx returns a 404 (which is suspiciously what the / location will do).</p>
  
  <p>The Let's Encrypt SSL cert seems to be working as expected, as I can serve static content (http requests are redirected from 80 to 443 via 301 status).</p>
  
  <p>My nginx default configuration looks like this:</p>
  
  <pre><code># HTTP - redirect all requests to HTTPS
  server {
      listen 80;
      listen [::]:80 default_server ipv6only=on;
      return 301 https://$host$request_uri;
  }
  
  # HTTPS - serve HTML from /usr/share/nginx/html, proxy requests to /parse/
  # through to Parse Server
  server {
      listen 443;
      server_name example.com;
  
      root /usr/share/nginx/html;
      index index.html index.htm;
  
      ssl on;
      # Use certificate and key provided by Let's Encrypt:
      ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
      ssl_session_timeout 5m;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_prefer_server_ciphers on;
      ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
  
      # Pass requests for /parse/ to Parse Server instance at localhost:1337
      location /parse/ {
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-NginX-Proxy true;
              proxy_pass http://localhost:1337/;
              proxy_ssl_session_reuse off;
              proxy_set_header Host $http_host;
              proxy_redirect off;
      }
  
      location / {
              try_files $uri $uri/ =404;
      }
  }
  </code></pre>
  
  <p>This is a typical line from nginx access.log:</p>
  
  <pre><code>xxx.xxx.xxx.xxx - - [20/Mar/2016:18:54:53 -0400] "PUT /parse/classes/_User/xxxxxxxxxx HTTP/1.1" 404 68 "-" ...
  </code></pre>
  
  <p>Is there any way to turn more verbose debugging on so I can tell why the match is failing?</p>
  
  <p>Thanks,
  peter</p>
  
  <p><strong>Solution (see below)</strong>
  Note the addition of /parse/ on the proxy_pass configuration</p>
  
  <pre><code>  location /parse/ {
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-NginX-Proxy true;
              proxy_pass http://localhost:1337/parse/;
              proxy_ssl_session_reuse off;
              proxy_set_header Host $http_host;
              proxy_redirect off;
      }
  </code></pre>