reactjs - Node.js 应用程序不会在我的公共 IP 上启动
问题描述
我正在通过 SSH 连接到一个学校项目的 linux shell。现在,我们正在尝试为 Web 前端设置一个 React 应用程序。我们能够轻松地在 localhost 上运行该应用程序,并且所有功能似乎都很好,但我不知道如何将其托管在计算机的公共 IP 上。我们一直在使用 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#
当我运行 hostname -I 时,public.facing.ip.address 根本不会出现。所以这似乎是一个显而易见的问题。这里的问题是我们也在同一台计算机的 public.facing.ip.address 的单独端口上运行 jenkins。这更容易设置,它只是作为我可以使用'systemctl start jenkins'作为服务启动的东西,然后它进入了面向公众的IP。我设置了所有这些,我可以很好地访问它,等等。我能做的最好的事情是在终端或 .env 文件中修改 HOST 变量,然后 yarn 在 localhost 上启动一个开发服务器(我可以' t 访问,因为我在不同的网络上通过 SSH 连接到这台计算机)
如何让 yarn 在面向公众的 IP 上托管我们的 webapp?
解决方案
打开你的路由器页面,某处应该有dmz主机选项,指向你的本地IP地址
推荐阅读
- javascript - 如何在谷歌表格中编译数据表?
- php - 我收到此错误“您的 Composer 依赖项需要 PHP 版本 >= 7.4.9”。您正在运行 7.4.8。“
- wagtail - 使用 api (wagtail) 创建新页面
- c# - C# WinForms - 代码在数组之前工作,但放在数组之后会失败
- python - 如何将 csv 转换为具有特定版本的 parquet 文件。(parquet-cpp 版本 1.5.1-SNAPSHOT)?
- terraform - Terraform cidrsubnet 函数
- c - 函数错误的参数太多,但函数显然需要两个参数
- c# - BindingSource 不向表中添加数据
- javascript - 清除 react-bootstrap 中的特定选择
- c# - 在等待挂起的操作取消时处置 SemaphoreSlim 是否安全?