简体   繁体   English

将sails.js应用程序绑定到特定的IP

[英]Bind sails.js app to a specific ip

I have a Nodejs project and is using sails.js mvc framework. 我有一个Nodejs项目,正在使用sails.js mvc框架。 Now, Im ready to deploy it, but before that one requirement is to bind it to a different ip. 现在,我准备部署它,但在此之前的一个要求是将其绑定到其他ip。 Is there a way on sails.js that we can achieve this? 在sails.js上有没有一种方法可以实现这一目标? What file or config should I update? 我应该更新什么文件或配置?

You have to change the 'host' key. 您必须更改“主机”密钥。 Source 资源

You can change the /config/local.js file and add the 'host' key to it : 您可以更改/config/local.js文件并向其中添加'host'键:

{
    port: '1234',
    host: '111.111.111.111',
    environment: 'production'
}

Source 资源

I've tried @xShirase answer and it worked too. 我尝试了@xShirase答案,它也起作用。 So I have it marked as answer. 因此,我将其标记为答案。 Anyhow, this is what I did on my end: 无论如何,这就是我最终所做的:

I added application.js on config, config/application.js then added this line module.exports.host = '<ip here>'; 我在配置上添加了application.jsconfig/application.js然后添加了这一行module.exports.host = '<ip here>';

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

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