简体   繁体   English

如何在node.js应用程序中使用publicIP:3000代替localhost:3000

[英]How to use publicIP:3000 in place of localhost:3000 in node.js application

i have a dedicated server(Virtual Machine) with xxx.xxx.xxx.xxx public IP address, how to publish node.js application on it ? 我有一个带有xxx.xxx.xxx.xxx公共IP地址的专用服务器(虚拟机),如何在其上发布node.js应用程序? . I should be able to browse my application from another PC via internet , have no idea , please help 我应该能够通过互联网从另一台PC浏览我的应用程序,不知道,请帮助

Difficult to say without seeing more of your project but this may have already been answered here . 很难说,看不到您的更多项目,但是这里可能已经回答

There is no configuration needed to make your external IP address work with node.js, unless and until you bind it otherwise. 除非您将其绑定,否则无需进行任何配置即可使您的外部IP地址与node.js一起使用。

Instead of .listen(PORT, IP_ADDRESS_OR_HOST ); 代替.listen(PORT,IP_ADDRESS_OR_HOST); use .listen(PORT); 使用.listen(PORT);

Then, just use IP_ADDRESS_OR_HOST:PORT to access it. 然后,只需使用IP_ADDRESS_OR_HOST:PORT即可访问它。

Edit: It occurred to me that you may not be aware of how the basics of websites work (not trying to insult you here, I just don't know how much work you've done already). 编辑:我想到您可能不知道网站的基础知识如何工作(不是在这里侮辱您,我只是不知道您已经完成了多少工作)。 Once you have exposed your application to respond on any IP, you need to forward port 80 from your gateway/router/firewall to the internal IP address of your VM running Node. 公开应用程序以对任何IP做出响应后,您需要将端口80从网关/路由器/防火墙转发到运行Node的VM的内部IP地址。

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

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