Linux: Apache Tomcat tips and tricks

JAVA_HOME or JRE_HOME variables are not defined:

Edit bash_profile for the user running Tomcat:
nano ~/.bash_profile

Add the following line and edit to point to correct directory:
export JRE_HOME=/usr/local/jre

Save and exit, then execute the following command:
source ~/.bash_profile

Running Apache Tomcat on privileged ports (lower then 1024) as non-root user:

The best way is to set an iptables rule to forwards incoming requests from port 80 to 8080:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
or setup apache with mod_jk connector to pass http requests to tomcat

Linux: Reset iptables firewall rules

Create a shell script (iptables_flush.sh) and copy paste the following lines:

#!/bin/sh
echo "Flushing iptables rules..."
sleep 1
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

Make the file executable
chmod +x iptables_flush.sh
and run the script:
./iptables_flush.sh