简体   繁体   English

Node.js 应用程序不会在我的公共 IP 上启动

[英]Node.js application wont start on my public IP

I'm SSHing into a linux shell for a school project.我正在通过 SSH 连接到学校项目的 linux shell。 Right now, we're trying to set up a react app for a web frontend.现在,我们正在尝试为 Web 前端设置 React 应用程序。 We were able to run the app on localhost easily enough, and all of the functionality seems to be good, but I can't figure out how to get this hosted on the public IP of the computer.我们能够很容易地在本地主机上运行该应用程序,并且所有功能似乎都很好,但我不知道如何将其托管在计算机的公共 IP 上。 We've been using yarn to do all of this, though i've tried other things, so here's some cli output.我们一直在使用 yarn 来完成所有这些,尽管我尝试了其他的东西,所以这里有一些 cli 输出。

path/to/thing# yarn start
yarn run v1.22.5
$ react-scripts start
Attempting to bind to HOST environment variable: public.facing.ip.address        //This is a website name
If this was unintentional, check that you haven't mistakenly set it in your shell.
Learn more here: //There was a link here but SO formatting wouln't let me keep it.

Could not find an open port at public.facing.ip.address.
Network error message: listen EADDRNOTAVAIL: address not available public.facing.ip.address  //numeric

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
root@computer:path/to/thing# 

When I run hostname -I, public.facing.ip.address does not appear at all.当我运行主机名 -I 时,public.looking.ip.address 根本没有出现。 So that seems like the obvious issue.所以这似乎是显而易见的问题。 The catch here is that we are also running jenkins on a separate port of public.facing.ip.address from this same computer.这里的问题是我们也在同一台计算机的 public.looking.ip.address 的单独端口上运行 jenkins。 That was much easier to set up, it just came as something I could start as a service using 'systemctl start jenkins' and up it went onto the public facing IP.这更容易设置,它只是作为我可以使用'systemctl start jenkins'作为服务启动的东西,然后它进入了面向公众的IP。 I set all that up and I can access it just fine, etc. The best I can do with this is modify the HOST variable either in the terminal or the .env file, then yarn starts a development server on localhost (which I can't access since I'm on a different network SSHing into this computer)我设置了所有这些,我可以很好地访问它,等等。我能做的最好的是修改终端或 .env 文件中的 HOST 变量,然后 yarn 在本地主机上启动一个开发服务器(我可以) t 访问,因为我在不同的网络上通过 SSH 连接到这台计算机)

How do I make yarn host our webapp on the public facing IP?我如何让纱线在面向公众的 IP 上托管我们的 web 应用程序?

打开您的路由器页面,某处应该有 dmz 主机选项,将其指向您的本地 IP 地址

My networking inexperience was the culprit.我的网络经验不足是罪魁祸首。 Instead of using HOST=path.to.public.ip, the solution was to use HOST=0.0.0.0.解决方案不是使用 HOST=path.to.public.ip,而是使用 HOST=0.0.0.0。

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

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