EC2(Amazon) 中的 Linux 无法为 tomcat 使用端口 80 [英] Linux in EC2(Amazon) cannot use port 80 for tomcat

查看:45
本文介绍了EC2(Amazon) 中的 Linux 无法为 tomcat 使用端口 80的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我只想看看它不是在 ec2 控制台中设置的安全组.因为我可以设置apache,这是80端口的故障,并且可以通过80端口访问apache网站.但是对于 tomcat,如果我使用端口 8080(默认情况下)或某些大于 1023 的值(我认为是这个端口),它就可以工作.但是当我更改 server.xml(将 8080 更改为 80)时,如果我使用 80 端口,它就无法工作,我成功启动了服务,但是没有 80/http 侦听.我知道这应该是一些权限问题(只有 root 可以在 1023 端口以下启动服务).但我不知道该怎么做.

First, i just want to see it is not security group setup in ec2 console. because i can setup the apache, which is by fault 80 port, and be able to visit the apache website through 80 port. but for tomcat it works if i use port 8080(by default) or some values bigger than 1023(i think this port). but when i change server.xml(changing 8080 to 80) it cannot work if i use 80 port, i start the service successfully, but there is no 80/http listening. I know it should be some privileges issues(only the root can start service below 1023 port). but i did not know how to do it.

推荐答案

我个人针对这个问题的选择是使用 iptables 将所有流量从 80 端口重定向到上层端口(例如 8080)Tomcat 正在运行.

My personal choice for this problem is to use iptables to redirect all traffic from port 80 to the upper port (e.g. 8080) the Tomcat is running on.

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

这篇关于EC2(Amazon) 中的 Linux 无法为 tomcat 使用端口 80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆