Start tomcat with port 80 without Linux root user-Use iptables mapping

[quote]In linux system. only root user can use the port small than 1024, so if you change tomcat port to 80 and start without root account, then you will see the following error: [/quote]
java.net.BindException: Permission denied <null>


[quote]The solution is to use iptables to map port 80 with the default port 8080[/quote]

#map tomcat port:8080  to port:80 , so the external host can access tomcat via both 8080 and 80
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

#let local application to access tomcat via port 80
iptables -t nat -I OUTPUT -p tcp -o lo --dport 80 -j REDIRECT --to-ports 8080

#save mapping, so after linux box reboot, still have these port mapping
service iptables save

#view existed port mapping
iptables -t nat --line-numbers -n -L
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值