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

时间:2016-05-07 13:05:31

标签: macos server wildfly portforwarding ports

我在我的家庭作业局域网中,我的Macintosh(Mac OS X El Capitan 10.11.4)的私有IP是192.168.1.9而我的防火墙是关闭的。 我已经在“http://localhost:8080/”上运行了一个wildfly 10 web项目,直到我从localhost访问该项目一切正常,当我尝试从http://192.168.1.9:8080/谷歌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“)。

1 个答案:

答案 0 :(得分:2)

从eclipse配置

如果你想从eclipse设置IP,你应该遵循以下步骤(因为设置了-b选项,更改文件standalone.xml中的IP不能从eclipse工作,请参阅下面的内容。 。)

这是在eclipse上配置它的步骤:

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

    standalone.xml

    配置

    另一种方法是在standalone.xml接口部分配置。

    更改:

    <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>
    

    或者简单地用您的私有IP替换127.0.0.1

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

    另一种方法是直接从命令行运行它。 默认情况下jboss / wildfly绑定到localhost,如果要更改它,可以执行:

    standalone.sh -b 0.0.0.0
    

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

    或者如果你想听你的IP:

    standalone.sh -b your_private_ip
    

    参考:

相关问题