简体   繁体   English

如何更改pm2 Web界面的IP和端口?

[英]How can I change the ip and port of pm2 web interface?

pm2 web interface - $pm2 web - listen on all the ip available on the machine and I would like it to only listen on localhost or ip of my choice. pm2 Web界面-$ pm2 web-监听机器上所有可用的ip,我希望它仅监听我选择的localhost或ip。

$pm2 web
Launching web interface on 0.0.0.0:9615
[PM2][WARN] Applications pm2-http-interface not running, starting...
[PM2] App [pm2-http-interface] launched (1 instances)
[PM2] Process launched


pm2 version 2.1.6
node version 4.7.3

Thanks 谢谢

EDITED: 编辑:

I have researched about the environment variables and for the ip and port are: 我已经研究了环境变量,并且对于ip和port是:

"env_production" : {
   "NODE_ENV": "production",
   "PM2_API_IPADDR" : "IP here",
   "PM2_API_PORT" : "PORT here"
},

I have tried to start the web interface using the ecosystem.json file and I can not get it. 我尝试使用econo.json文件启动Web界面,但无法获取。

I am going to open another question on this subject. 我将就这个问题再提出一个问题。

How to start pm2 http web interface using the ecosystem.json file? 如何使用生态系统.json文件启动pm2 http Web界面?

To start the pm2 web interface with a different port and/or different listening address you can run it with the environment variable you found set. 要使用其他端口和/或不同的侦听地址启动pm2 Web界面,可以使用您发现的环境变量来运行它。

eg. 例如。 PM2_API_PORT=1234 PM2_API_IPADDR=192.168.1.1 pm2 web

I recommend setting the environment variables in your ecosystem.json file. 我建议在您的ecosystem.json文件中设置环境变量。

So for example, I usually set NODE_ENV to be production / development or PORT to be 8080 and maybe, in your case, HOST to be localhost . 因此,例如,我通常将NODE_ENV设置为production / development或者将PORT设置为8080并且在您的情况下,可能将HOST设置为localhost

To access them in your node application, use process.env.<ENVIRONMENT VAR HERE> . 要在节点应用程序中访问它们,请使用process.env.<ENVIRONMENT VAR HERE>

So for example in your javascript: var port_num = process.env.NODE_ENV; 例如,在您的javascript中: var port_num = process.env.NODE_ENV;

Here's the pm2 documentation on how to set the environment variables, under the env property: http://pm2.keymetrics.io/docs/usage/deployment/ 这是有关如何在env属性下设置环境变量的pm2文档: http : //pm2.keymetrics.io/docs/usage/deployment/

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

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