我无法从 Parse Dashboard 上传 PFFile(图片),当我的解析服务器使用 https 时,当我尝试在浏览器上访问它时,我得到 404

I can't upload PFFile (image) from Parse Dashboard and I get 404 when I try to access it on browser when my parse server uses https

我在 Digital Ocean 上有一个使用 nginx 代理方法的 https 解析服务器。我的解析服务器 url 就像 https://my-domain.com/myappname。我已将此 link 添加到 index.js 文件中解析服务器的 publicServerURL 以用于 mailgun 和文件。

我还在 Parse Dashboard 的 config.json 文件中添加了这个 link 作为 serverURL。 我试图通过 Parse Dashboard 上传一个 pffile(图像),但它说 Unable to connect to Parse API 。 当我将 config.json 文件中的 serverURL 从 https://my-domain.com/myappname 更改为 http://server-ip:port/parse 时,它工作正常,但是当我尝试从数据库中删除一行时出现错误(使用 https 可以正常工作)

我在 /etc/nginx/sites-enabled/my-domain.com 中的文件如下(我还将我的网站与我的解析服务器托管在同一台服务器上):

server {

        root /var/www/my-domain.com/html;
        index index.php index.html index.htm index.nginx-debian.html;
        client_max_body_size 100m;
        server_name my-domain.com www.my-domain.com;


        location / {
               if ($request_uri ~ ^/(.*)\.html$) {
                    return 302 /;
                }
               #try_files $uri $uri/ =404;
               try_files $uri $uri.html $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }

        location /myparseapp {
                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;
        }


    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/my-domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/my-domain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = www.my-domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = my-domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        listen [::]:80;

        server_name my-domain.com www.my-domain.com;
    return 404; # managed by Certbot

}

我也无法通过网络浏览器访问上传的 PFFile(image)。 url https://my-domain.com/myappname/files/11d51c92517ace2d17bc376f2da99a50_default.png 说 404 Not Found nginx/1.14.0 (Ubuntu)

终于找到解决办法了!!!

我使用 subdomain.my-domain.com 而不是 my-domain.com/myapp 并且在 nginx 配置中我删除了 try_files $uri $uri/ =404; 并输入了 follow

location / {
                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;
        }

您需要在 proxy_pass 的末尾添加 / 才能使图像在您的浏览器上运行。