parse-server: nginx 404 proxying parse-server requests (digitalocean ubuntu)

(cross-posted on stack overflow)

I am migrating parse-server to a DigitalOcean Ubuntu droplet based on this documentation:

How To Migrate a Parse App to Parse Server on Ubuntu 14.04

I’m having an issue with nginx proxying (https) requests to parse-server.

If I open port 1337 on my droplet and configure Parse http requests to go directly to parse-server (http://example.com:1337/parse), this all works as expected.

If I configure Parse http requests to go to https://example.com/parse, nginx fails to proxy the request to parse-server.

nginx returns a 404 (which is suspiciously what the / location will do).

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).

My nginx default configuration looks like this:

# 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;
    }
}

This is a typical line from nginx access.log:

xxx.xxx.xxx.xxx - - [20/Mar/2016:18:54:53 -0400] "PUT /parse/classes/_User/xxxxxxxxxx HTTP/1.1" 404 68 "-" ...

Is there any way to turn more verbose debugging on so I can tell why the match is failing?

Thanks, peter

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

proxy_pass http://localhost:1337/;

did you try proxy_pass http://localhost:1337/parse/;

@flovilmart Your answer above was the solution. I think the reason that it did not work when I allegedly “tried it”, was that I didn’t have the trailing slash on http://localhost:1337/parse**/**. My apologies for the inaccuracy. Thank you.