Why does Tomcat work with port 8080 but not 80?

荒凉一梦 提交于 2019-11-27 01:36:39

问题


I have started and tested Tomcat under Port 8080 (default). Now I altered the connector port to 80 and restarted Tomcat, nothing will show on my minimal Debian 6.0 installation. Now where is the trick here?

<Connector port="80" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           URIEncoding="UTF-8"
           redirectPort="8443" />

回答1:


go to /etc/default/tomcat6 and change #AUTHBIND=no to AUTHBIND=yes

 # If you run Tomcat on port numbers that are all higher than 1023, then you
 # do not need authbind.  It is used for binding Tomcat to lower port numbers.
 # NOTE: authbind works only with IPv4.  Do not enable it when using IPv6.
 # (yes/no, default: no)
 #AUTHBIND=no



回答2:


Two typical reasons:

  • You quite possibly don't have permission to listen to a port lower than 1024 (usually requires administrative privileges, e.g. being root)
  • Something else may already be listening on port 80 (e.g. apache)



回答3:


Did you start Tomcat on port 80 as root? You have to be root to bind to ports <= 1024 in Linux.




回答4:


If nothing of the commented before works (like it happened to me), you can direct the traffic from the port 80 to the 8080.

To do it:

http://forum.slicehost.com/index.php?p=/discussion/2497/iptables-redirect-port-80-to-port-8080/p1

In a nutshell, type this three commands in a terminal:

$ sudo iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
$ sudo iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
$ sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080 



回答5:


Run your startup script as root after changing the binding.

sudo ./<path to tomcat bin director>/startup.sh



回答6:


stop apache service and then run tomcat you should be good , by default apache is running on port 80




回答7:


You can use authbind/privbind or capabilities to bind to port 80.



来源:https://stackoverflow.com/questions/10450045/why-does-tomcat-work-with-port-8080-but-not-80

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!