为什么Tomcat一开始就以0.0.0.0:8000打开?
我知道简短的答案是“你告诉它的”。但当然,我不确定如何告诉 Tomcat 以打开 8000
默认调试端口启动,但在 0.0.0.0
而不是预期的 127.0 .0.1
。以下是 Ubuntu 10.10 启动后的几个上下文命令。
$ netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN
tcp6 0 0 127.0.0.1:8080 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 127.0.0.1:8005 :::* LISTEN
/usr/share/tomcat6/bin$ grep -C 5 8000 catalina.sh
#
# JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start"
# command is executed. The default is "dt_socket".
#
# JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start"
# command is executed. The default is 8000.
#
# JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start"
# command is executed. Specifies whether JVM should suspend
# execution immediately after startup. Default is "n".
#
--
if [ "$1" = "jpda" ] ; then
if [ -z "$JPDA_TRANSPORT" ]; then
JPDA_TRANSPORT="dt_socket"
fi
if [ -z "$JPDA_ADDRESS" ]; then
JPDA_ADDRESS="8000"
fi
if [ -z "$JPDA_SUSPEND" ]; then
JPDA_SUSPEND="n"
fi
if [ -z "$JPDA_OPTS" ]; then
鉴于这两个输出,我希望发现在我不知情的情况下修改了某个地方的进一步配置文件,因为 catalina.sh
打开 8000
的唯一方法是如果它已通过jpda
开关,即使如此,它似乎也会在localhost
上启动,而不是0.0.0.0
。 .bashrc
没有任何 tomcat 的愚蠢行为,我不知道还能去哪里寻找!
I know the short answer is "You told it to." But of course, I'm not sure how I told Tomcat to start with the 8000
default debug port open, but on 0.0.0.0
instead of the expected 127.0.0.1
. Here's a couple of context commands directly after Ubuntu 10.10 boots.
$ netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN
tcp6 0 0 127.0.0.1:8080 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 127.0.0.1:8005 :::* LISTEN
/usr/share/tomcat6/bin$ grep -C 5 8000 catalina.sh
#
# JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start"
# command is executed. The default is "dt_socket".
#
# JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start"
# command is executed. The default is 8000.
#
# JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start"
# command is executed. Specifies whether JVM should suspend
# execution immediately after startup. Default is "n".
#
--
if [ "$1" = "jpda" ] ; then
if [ -z "$JPDA_TRANSPORT" ]; then
JPDA_TRANSPORT="dt_socket"
fi
if [ -z "$JPDA_ADDRESS" ]; then
JPDA_ADDRESS="8000"
fi
if [ -z "$JPDA_SUSPEND" ]; then
JPDA_SUSPEND="n"
fi
if [ -z "$JPDA_OPTS" ]; then
Given these two outputs, I expect to find out that there's a further configuration file somewhere that I unknowingly modified, since the only way that catalina.sh
would open 8000
is if it was passed the jpda
switch, and even then it seems like it will start on localhost
and no 0.0.0.0
. .bashrc
is clean of tomcat tomfoolery, and I'm stumped where else to look!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是时候复习一下 RFC4632了,记忆已经生锈了。
0.0.0.0是默认路由,在Tomcat的情况下用于指示<端口
8000
上的任何 IP 都将被路由到 Tomcat(大概是为了调试)。重申一下,在 Tomcat 上
0.0.0.0:xxxx
会将任何具有xxxx
端口的请求路由到 Tomcat。Time to brush up on RFC4632, memory got rusty.
0.0.0.0 is the default route, and in the case of Tomcat is used to indicate that any IP on port
8000
will be routed into Tomcat (presumably for debugging).To restate, on Tomcat
0.0.0.0:xxxx
will route any request withxxxx
port into Tomcat.这可能是因为 JPDA_ADDRESS 是“8000”而不是“localhost:8000”
if [ -z "$JPDA_ADDRESS" ];然后
JPDA_ADDRESS =“本地主机:8000”
菲
That could be becuase the JPDA_ADDRESS is "8000" and not "localhost:8000"
if [ -z "$JPDA_ADDRESS" ]; then
JPDA_ADDRESS="localhost:8000"
fi