Tomcat中不能通过访问自己IP,但可以通过localhost/127.0.0.1访问

一、问题如下:局域网内,自己机器部署了一个tomcat应用,在本机上可以通过如下方式访问引用。

     http://localhost:8080/xxxx

    http://127.0.0.1:8080/xxxx

   假如我的机器的IP是192.168.1.100, 但是无法通过如下方式(IP)访问:

  http://192.168.1.100:8080/xxxx 发现无法访问。

二.解决思路

    情况①防火墙/杀毒软件问题,都关闭 

    情况②tomcat绑定IP地址的问题,先通过使用cmd命令netstat -n, 查看tomcat地址绑定, 发现是绑定到::1, IPv6.

      故我们再将其绑定至IP4本机地址即可 具体操作如下:

      配置tomcat的server.xml, 更改connector配置, 端口不用改, 加上address="0.0.0.0", 使其绑定到IPv4, 如下:

    <1>使用cmd命令netstat -n, 查看tomcat地址绑定, 发现是绑定到::1, IPv6;
    <2>配置tomcat的server.xml, 更改connector配置, 端口不用改, 加上address="0.0.0.0", 使其绑定到IPv4
    <!-- A "Connector" represents an endpoint by which requests are received  and responses are returned. Documentation at :  Java HTTP Connector: /docs/config/http.html  Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html  Define a non-SSL/TLS HTTP/1.1 Connector on port 8080-->         
      <Connector port="8080" protocol="HTTP/1.1"    address="0.0.0.0" connectionTimeout="20000"  redirectPort="8443" />   加入红字部分内容即可

    情况③IP地址被adsafe等代理软件代理了,关掉相关软件即可——此情况很难想到

 文章内容解决方法转自   https://bbs.csdn.net/topics/391915128?page=1  

            https://blog.csdn.net/xinyue3054/article/details/7895166

                        

猜你喜欢

转载自www.cnblogs.com/12three/p/11127338.html