简体   繁体   English

从与8080不同的端口在浏览器中打开tomcat

[英]Opening tomcat from the browser on different port than 8080

I have nginx on 8080 port installed on my CentOS server, and I have installed java tomcat additionaly. 我在CentOS服务器上安装了8080端口的Nginx,并且已经安装了Java tomcat另外。 It's also on 8080 by default, so I changed the port to some free one - 8085. The problem is that trying to get a response from it by opening http://122.21.32.33:8085/ gives me page not found error. 默认情况下它也在8080上,因此我将端口更改为一些免费端口-8085。问题是,尝试通过打开http://122.21.32.33:8085/来获得响应,这给了我page not found错误。

Why is that so? 为什么会这样?

The service is started, I changed the connector tag in server.xml to: 服务启动后,我将server.xml的连接器标记更改为:

 <Connector port="8085" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               useIPVHosts="true" />

Firing netstat -ntpl | grep java 触发netstat -ntpl | grep java netstat -ntpl | grep java gives me: netstat -ntpl | grep java给我:

tcp6       0      0 :::8009                 :::*                    LISTEN      8818/java
tcp6       0      0 :::8085                 :::*                    LISTEN      8818/java
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      8818/java

ps -ef | grep tomcat ps -ef | grep tomcat gives me: ps -ef | grep tomcat给了我:

tomcat    8818     1  0 17:56 ?        00:00:01 /usr/lib/jvm/jre/bin/java -Djava.security.egd=file:/dev/./urandom -Djava.aw...
root      8862  8144  0 18:00 pts/1    00:00:00 grep --color=auto tomcat

Ports 8818 and 8862 don't work either. 端口8818和8862也不起作用。 What's wrong? 怎么了?

Your netstat-Output says, that you are listening on IPv6. 您的netstat-Output表示您正在侦听IPv6。 Then you try to connect form your browser via IPv4. 然后,您尝试通过IPv4与浏览器建立连接。 You need to configure tomcat to make it listen on IPv4: 您需要配置tomcat以使其在IPv4上侦听:

You basically have to add this: 您基本上必须添加以下内容:

JAVA_OPTS= "$JAVA_OPTS -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses"

to the end of your catalina.sh file. catalina.sh文件的末尾。

Here is a full guide in case you need it. 如果需要,这里有完整的指南

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

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