tomcat8.5只监听本地ipv4端口

  1. 云栖社区>
  2. 博客>
  3. 正文

tomcat8.5只监听本地ipv4端口

eyunshu 2019-01-10 15:51:13 浏览980
展开阅读全文

环境:Freebsd 12.0,openjdk8,tomcat8.5


首先,在/etc/rc.conf里加入


# tomcat enable
tomcat85_enable="YES"
tomcat85_java_opts="-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true"

然后修改tomcat的配置文件conf/server.xml,以下两个地方加入address="127.0.0.1"


<Connector executor="tomcatThreadPool"
               address="127.0.0.1"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               URIEncoding="UTF-8" />

.....


<!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector address="127.0.0.1" port="8009" protocol="AJP/1.3" redirectPort="8443" />

然后用netstat -anp tcp查看,应该是类似如下的输出了


Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address          Foreign Address        (state)
tcp4       0      0 127.0.0.1.8009         *.*                    LISTEN
tcp4       0      0 127.0.0.1.8080         *.*                    LISTEN
tcp4       0      0 *.80                   *.*                    LISTEN
tcp4       0     48 172.16.16.16.22        121.207.132.35.29369   ESTABLISHED
tcp4       0      0 *.22                   *.*                    LISTEN


网友评论

登录后评论
0/500
评论
eyunshu
+ 关注