I'm wondering on how I can migrate different apps to the same server, I'm using PM2 to ensure it's always running.
Here is my ecosystem file
{
"apps" : [{
"name" : "parse-wrapper",
"script" : "/usr/bin/parse-server",
"watch" : true,
"merge_logs" : true,
"cwd" : "/home/parse",
"env": {
"PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js",
"PARSE_SERVER_DATABASE_URI": "mongodb://parse:password@your_domain_name:27017/database_name?ssl=true",
"PARSE_SERVER_APPLICATION_ID": "your_application_id",
"PARSE_SERVER_MASTER_KEY": "your_master_key",
}
}]
}
Shoud I use the same ecosystem file or should I create a new one and run ??
PM2 start
How to configure the URL to different apps in Nginx
location /app1/ {
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;
}
This is how I have mine setup, but you should also create a new ecosystem for each api you have running. But for the .info file in the NGINX you should list all of your app locations like this:
location /app1/ {
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 /app2/ {
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:1338/parse/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_redirect off;
}
So I was able to set up multiple parse apps with the following configuration:
My ecosystem.json:
{ "apps" : [ { "name" : "first app", "script" : "parse-server", "ignore_watch": ["logs"], "watch" : true, "merge_logs" : true, "cwd" : "/root/parse-server/", "env": { "PARSE_SERVER_CLOUD_CODE_MAIN": "/root/cloud/main.js", "PARSE_SERVER_DATABASE_URI": "mongodb://localhost:27017/DATABASE_NAME", "PARSE_SERVER_APPLICATION_ID": "<APP_ID>", "PARSE_SERVER_MASTER_KEY": "APP_MASTER_KEY", "PORT": "1337", "PARSE_SERVER_URL": "http://localhost:1337/parse", } }, { "name" : "second app", "script" : "parse-server", "ignore_watch": ["logs"], "watch" : true, "merge_logs" : true, "cwd" : "/root/parse-server/", "env": { "PARSE_SERVER_CLOUD_CODE_MAIN": "/root/pace-app/cloud/main.js", "PARSE_SERVER_DATABASE_URI": "mongodb://localhost:27017/logisticsDB", "PARSE_SERVER_APPLICATION_ID": "<APP_ID>", "PARSE_SERVER_MASTER_KEY": "<APP_MASTER_KEY>", "PORT": "1338", "PARSE_SERVER_URL": "http://localhost/app2", } }, { "name" : "dashboard", "script" : "parse-dashboard", "watch" : true, "merge_logs" : true, "cwd" : "/usr/local/bin/", "args" : "--config /root/dashboard.json --allowInsecureHTTP true" }] }
My dashboard.json:
{ "allowInsecureHTTP": true, "apps": [ { "serverURL": "http://somedomain:1337/parse", "appId": "<APP_ID>", "masterKey": "<APP_MASTER_KEY>", "appName": "APP 1" }, { "serverURL": "https://somedomain/app2", "appId": "<APP_ID>", "masterKey": "<APP_MASTER_KEY>", "appName": "App 2" } ], "users": [ { "user": "user", "pass": "pass", "apps": [{ "appId": "<APP_ID>" }] }, { "user": "admin", "pass": "admin", "apps": [{ "appId": "<APP_ID>" }] } ] }
My /etc/nginx/sites-enabled/default was something similar to what user1959311 has.
Hope it helps.
Cheers
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.