0

I am relatively new in working with servers so apologies if my question is not explained properly.

I have hosted my Parse-Server on DigitalOcean by following these tutorials
1. www.digitalocean.com/community/tutorials/how-to-migrate-a-parse-app-to-parse-server-on-ubuntu-14-04
2. www.digitalocean.com/community/tutorials/how-to-secure-nginx-on-ubuntu-14-04

Everything works nicely except when my iOS App tries to fetch any File (PFFile using URL) it encounters an error saying "CFNetwork SSLHandshake failed (-9806)" and in browser I get "cannot establish secure connection to server".

File URL that I am trying to fetch is - "https://cobbet.com:1337/parse/files/IpFrZ8h4ZFjv9fKhUq3p7C2ca2WOBuAkbbzmtrxe/50c99849-9e31-4414-9552-f640fb43eb53_iphone_6.png"

However, If I change "https" to "http" and replace my domain_name "cobbet.com" by actual IP Address "104.236.228.111", I am able to access the file on browser.

File URL that works - "http://104.236.228.111:1337/parse/files/IpFrZ8h4ZFjv9fKhUq3p7C2ca2WOBuAkbbzmtrxe/50c99849-9e31-4414-9552-f640fb43eb53_iphone_6.png"


My Nginx Server Configuration is

# HTTP - redirect all requests to HTTPS
server {
    listen 80;
    server_name cobbet.com
    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 default_server ssl;
        server_name cobbet.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/cobbet.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/cobbet.com/privkey.pem;
        ssl_session_timeout 10m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128$
        ssl_dhparam /etc/ssl/certs/dhparam.pem;
        ssl_stapling on;
        ssl_stapling_verify on;
        add_header Strict-Transport-Security max-age=15768000;

        location ~ /.well-known {
                allow all;
        }


        # 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/parse/;
                proxy_ssl_session_reuse off;
                proxy_set_header Host $http_host;
                proxy_redirect off;
        }

        # Pass requests for /dashboard/ to Parse Server instance at localhost:4040
        location /dashboard/ {
                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:4040/dashboard/;
                proxy_ssl_session_reuse off;
                proxy_set_header Host $http_host;
                proxy_redirect off;
        }



        location / {
                try_files $uri $uri/ =404;
        }
}


How can I resolve this issue so that my app can download files without SSL error?

Thanks!

user3805150
  • 3
  • 1
  • 4

1 Answers1

1

You have mixed up your ports:

This http://104.236.228.111:1337/parse/files/IpFrZ8h4ZFjv9fKhUq3p7C2ca2WOBuAkbbzmtrxe/50c99849-9e31-4414-9552-f640fb43eb53_iphone_6.png bypasses nginx and goes directly to your backend, which is listening on this server on port 1337.

This https://cobbet.com:1337/parse/files/IpFrZ8h4ZFjv9fKhUq3p7C2ca2WOBuAkbbzmtrxe/50c99849-9e31-4414-9552-f640fb43eb53_iphone_6.png also tries to connect to your backend on 1337, but your backend does not serve https on that port.

The correct URL to access nginx is https://cobbet.com/parse/files/IpFrZ8h4ZFjv9fKhUq3p7C2ca2WOBuAkbbzmtrxe/50c99849-9e31-4414-9552-f640fb43eb53_iphone_6.png

You do not need the port as the client knows that the https port is 443. Acessing this with a browser shows content and a working Let's encrypt certificate, so this should be working.

Note: Exposing your backend port (1337) to the internet is generally not a good idea. Either close the port in your firewall or at least bind the backend application to the ip 127.0.0.1 (instead of 0.0.0.0).

Digitalkapitaen
  • 2,353
  • 13
  • 17