我对维护 Parse 还很陌生,但我已经快要疯了 ;)
我们在 Debian 机器上设置了一个解析服务器。它运行 nginx 并使用 pm2 来部署 Parse。Parse-Dashboard 运行良好,甚至我们的解析服务器也弹出了它的 mongodb。但是,该服务器似乎无法正常工作。我们可以访问domain.com/parse/serverinfo
并domain.com/parse/users
显示正确的用户列表。但是,从我们的云代码调用任何函数都是不可能的……它不起作用。
我反复在 Google 上搜索这个问题,似乎最多只能找到人们错误配置mount
参数的情况index.js
。然而,我们的情况并非如此。
这是我们的index.js:
// Example express application adding the parse-server module to expose Parse
// compatible API routes.
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');
var S3Adapter = require('parse-server').S3Adapter;
var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}
var protocol = process.env.HTTPS ? 'https://' : 'http://';
var port = process.env.PORT || 1337;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://****:****@api.domain.com:27017/parse' || 'mo$
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || '*****',
masterKey: process.env.MASTER_KEY || '*****', //Add your master$
fileKey: process.env.FILE_KEY || '*****',
serverURL: 'http://api.domain.com:' + port + '/parse' || process.env.SERVER_URL || protocol + $
liveQuery: {
classNames: ["Posts", "Comments"]
},
publicServerURL: 'http://api.domain.com:' + port + '/parse',
filesAdapter: new S3Adapter(
"*****",
"/*****/*****",
"*****", {
directAccess: true
}
)
});
var app = express();
var publicServerURL = "http://api.domain.com:1337/parse";
app.use('/public', express.static(path.join(__dirname, '/public')));
console.log("Mounth path: " + process.env.PARSE_MOUNT);
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);
app.get('/', function(req, res) {
res.status(200).send('I dream of being a website. Please star the parse-server repo on GitHub!');
});
app.get('/test', function(req, res) {
res.sendFile(path.join(__dirname, '/public/test.html'));
});
console.log('serverUrl configured as', protocol + 'localhost:' + port + '/parse');
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});
ParseServer.createLiveQueryServer(httpServer);
Nginx 配置是:
# 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 api.domain.com;
root /usr/share/nginx/html;
index index.html index.htm;
ssl on;
ssl_certificate /etc/nginx/certificates/api.domain.com.crt;
ssl_certificate_key /etc/nginx/certificates/api.domain.com.key;
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/parse/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_redirect off;
}
location / {
try_files $uri $uri/ =404;
}
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://00.000.00.000:4040/dashboard/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_redirect off;
}
}
我不知道我们的配置哪里出了问题,以及为什么会出现这种情况parse/users
。parse/serverinfo
做工作