繁体   English   中英

如何使用PM2和Nginx使用多个解析应用程序

[英]How to use multiple parse apps using PM2 and Nginx

我想知道如何将不同的应用程序迁移到同一台服务器,我正在使用PM2来确保它始终在运行。

这是我的生态系统文件

{
  "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",
    }
  }]
}

我应该使用相同的生态系统文件,还是应该创建一个新文件并运行?

PM2开始

如何在Nginx中配置不同应用程序的URL

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;
    }

这就是我设置我的方法,但你也应该为你运行的每个api创建一个新的生态系统。 但对于NGINX中的.info文件,您应列出所有应用位置,如下所示:

        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;
}

所以我能够使用以下配置设置多个解析应用程序:

我的生态系统.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" }] } 

我的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>" }] } ] } 

我的/ etc / nginx / sites-enabled / default与user1959311类似。

希望能帮助到你。

干杯

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM