我正在ubuntu
AWS实例托管的计算机上运行tomcat服务器。我可以通过到达服务器,public_ip:8080
但是当我将侦听端口server.xml
从更改8080
为80
连接时,远程主机会拒绝。
端口号80
已启用AWS firewall
。
我检查了ufw
通过,sudo ufw status
但结果是inactive
是ufw
底层防火墙机制的前端吗?
如何启用端口80
上firewall
?
预先感谢。
的输出iptables -S
:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
输出 netstat -punta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 785/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 613/sshd
tcp 0 0 172.31.1.56:22 92.45.23.114:3913 ESTABLISHED 5825/sshd: ubuntu [
tcp 0 0 172.31.1.56:22 92.45.23.114:19374 ESTABLISHED 7320/sshd: ubuntu [
tcp 0 0 172.31.1.56:22 92.45.23.114:28051 ESTABLISHED 6901/sshd: ubuntu [
tcp 0 272 172.31.1.56:22 92.45.23.114:9327 ESTABLISHED 7428/sshd: ubuntu [
tcp 0 0 172.31.1.56:22 92.45.23.114:7597 ESTABLISHED 7034/sshd: ubuntu [
tcp 0 0 127.0.0.1:3306 127.0.0.1:45655 ESTABLISHED 785/mysqld
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 7275/java
tcp6 0 0 :::8080 :::* LISTEN 7275/java
tcp6 0 0 :::22 :::* LISTEN 613/sshd
tcp6 0 0 127.0.0.1:45655 127.0.0.1:3306 ESTABLISHED 7275/java
udp 0 0 0.0.0.0:68 0.0.0.0:* 538/dhclient3
netstat -na |grep \:80
将端口更改为之前的输出80
:
tcp6 0 0 127.0.0.1:8005 :::* LISTEN
tcp6 0 0 :::8080 :::* LISTEN
netstat -na |grep \:80
将端口更改为后的输出80
:
tcp6 0 0 127.0.0.1:8005 :::* LISTEN
浏览器在端口上的输出80
:
ERROR
The requested URL could not be retrieved
The following error was encountered while trying to retrieve the URL: http://54.194.236.229/TransportationAutomation/personnel.xhtml
Connection to 54.194.236.229 failed.
The system returned: (111) Connection refused
The remote host or network may be down. Please try the request again.
Your cache administrator is webmaster.
Generated Fri, 14 Feb 2014 15:01:06 GMT by proxy (squid/2.7.STABLE7)
端口定义部分 server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />
在启动tomcat时Catalina.out的一部分port 80
:
Feb 14, 2014 3:04:25 PM org.apache.coyote.AbstractProtocol init
SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-80"]
java.net.BindException: Permission denied <null>:80
at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:391)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:554)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:409)
at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:956)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:815)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:594)
at org.apache.catalina.startup.Catalina.load(Catalina.java:619)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:449)
Caused by: java.net.BindException: Permission denied
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at java.net.ServerSocket.<init>(ServerSocket.java:181)
at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:49)
at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:378)
... 17 more
更新2:
我通过安装了tomcat,apt-get
所以它是tomcat的重新打包版本。这里说以root身份运行tomcat可以解决问题,但是这里说Tomcat should not be run under the root user.
没有重新包装的tomcat实例来处理它的方法吗?
更新3:
我想这就是我的问题的答案
请考虑包括server.xml的相关部分,iptables -S的输出以及理想情况下在运行tomcat的情况下netstat -punta的相关输出。
—
丹尼尔·威德里克
如果使用来安装Tomcat
—
David Levesque 2014年
apt-get
,我只想指出更改端口server.xml
通常是不够的,因为端口80是特权端口。您是否签入catalina.out
了看是否有任何错误消息?
在更改server.xml中的端口之前,netstat -na | grep \:80的输出是什么?然后,在server.xml中更改端口并重新启动jetty后,netstat -na | grep \:80的输出是什么?这似乎不是防火墙问题。
—
meatflag 2014年
我正在运行debian wheezy,发现我需要编辑/ etc / default / tomcat7而不是/etc/init.d/tomcat7
—
Ruut 2014年