require('dotenv').config();
var express = require('express');
//var http = require('http');
//var https = require('https');
var ParseServer = require('parse-server').ParseServer;
var ParseDashboard = require('parse-dashboard');
//var fs = require('fs');
var app = express();
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
//var allowInsecureHTTP = true;
//var options = {
// key: fs.readFileSync('/etc/ssl/key.pem', 'utf8'),
// cert: fs.readFileSync('/etc/ssl/cert.pem', 'utf8'),
//};
var S3Adapter = require("@parse/s3-files-adapter");
var AWS = require("aws-sdk");
//Configure Digital Ocean Spaces EndPoint
const spacesEndpoint = new AWS.Endpoint(process.env.SPACES_ENDPOINT);
var s3Options = {
bucket: process.env.SPACES_BUCKET_NAME,
baseUrl: process.env.SPACES_BASE_URL,
region: process.env.SPACES_REGION,
directAccess: true,
globalCacheControl: "public, max-age=31536000",
//bucketPrefix: process.env.SPACES_BUCKET_PREFIX,
s3overrides: {
accessKeyId: process.env.SPACES_ACCESS_KEY,
secretAccessKey: process.env.SPACES_SECRET_KEY,
endpoint: spacesEndpoint
}
};
var s3Adapter = new S3Adapter(s3Options);
var api = new ParseServer({
appName: 'Medo',
maxUploadSize: "200mb",
databaseURI: 'mongodb://adminmed:[email protected]:27017/meddb',
cloud:__dirname + '/cloud/main.js' ,
appId: process.env.APPID,
masterKey: process.env.MASTERKEY,
//fileKey: process.env.FILEKEY,
// publicServerURL: 'http://ip/parse',
serverURL: 'http://localhost:1337/parse-med/',
//filesAdapter: {
// "module": "@parse/s3-files-adapter",
// "options": {
// "bucket": process.env.S3_BUCKET,
// }
// },
filesAdapter: s3Adapter
});
// Serve the Parse API on the /parse URL prefix
app.use('/parse-med', api);
var port = 1337;
//var httpsServer = require('https').createServer(options,app).listen(port, function() {
//console.log('parse-server running on SSL port ' + port + '.');
//});
app.listen(port, function() {
console.log('parse-server running on port ' + port);
});
nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 650;
types_hash_max_size 2048;
client_max_body_size 500M;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
client_body_buffer_size 5M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}