繁体   English   中英

我可以从浏览器“ http:// localhost:8080 /”访问,但不能访问“ my_private_ip:8080 /”

[英]I can reach from browser “http://localhost:8080/” but not “my_private_ip:8080/”

我在家庭作业局域网中,Macintosh(Mac OS X El Capitan 10.11.4)的专用IP为192.168.1.9,防火墙关闭。 当我尝试从http://192.168.1.9:8080/ google访问它时,我已经在“ http:// localhost:8080 / ”上运行了一个wildfly 10 web项目,直到我从本地主机访问该项目为止一切正常。 chrome告诉我:

This site can’t be reached
192.168.1.9 refused to connect.
Search Google for 192 168 8080
ERR_CONNECTION_REFUSED

我需要从外部移动设备访问它,但是如果我什至不能从计算机本身的IP从自己的计算机访问它,则很难传递给移动设备...

奇怪的是,我还在端口80上监听了MAMP Apache端口,实际上“ http:// localhost / ”和“ http://192.168.1.9/ ”都可以正常工作(向我展示了默认的MAMP“ www /index.php”)。

从Eclipse配置

如果要从eclipse设置IP,则应遵循以下步骤(由于设置了-b选项,因此从eclipse更改文件standalone.xml中的IP无效,请参见下文...)

这些是在eclipse上进行配置的步骤:

  1. 单击您的Wildfly服务器 Wildfly服务器
  2. 单击Open Launch Configuration Wildfly服务器配置 取消选中Always update arguments related to the runtime的“ Always update arguments related to the runtime ,然后使用your_private_ip更改-b选项(如果删除选项-b localhost ,则可以直接从standalone.xml文件中对其进行配置,请参阅以下部分进行配置) 编辑Wildfly服务器配置
  3. 或者简单地,而不是2.解决方案,请选中“ Listen on all interfaces to allow remote web connections ”框Listen on all interfaces to allow remote web connections

standalone.xml配置

另一种方法是在standalone.xml的interfaces部分中配置。

更改:

<interfaces>
  <interface name="management">
   <inet-address value="127.0.0.1"/>
  </interface>
  <interface name="public">
   <inet-address value="127.0.0.1"/>
  </interface>
</interfaces>

至:

<interfaces>
  <interface name="management">
   <!-- Use the IPv4 wildcard address -->
   <any-ipv4-address/>
  </interface>
  <interface name="public">
   <!-- Use the IPv4 wildcard address -->
   <any-ipv4-address/>
  </interface>
</interfaces>

或只需将127.0.0.1替换为您的专用IP


从命令行配置(从命令行运行服务器)

另一种选择是直接从命令行运行它。 默认情况下,jboss / wildfly绑定到本地主机,如果要更改此设置,可以执行:

standalone.sh -b 0.0.0.0

侦听计算机的所有IP地址(如果是多宿主的)

或者,如果您想在IP上收听:

standalone.sh -b your_private_ip

参考:

暂无
暂无

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

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