`

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

 
阅读更多
引用
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:

java.net.BindException: Permission denied <null>


引用
The solution is to use iptables to map port 80 with the default port 8080


#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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics