I am newbie to linux firewalls and trying to setup my systems firewall for a public facing computer. Here are my requirements:
- Ports 80 and 22 should be open for HTTP requests and SSH logins
- Since my app server is going to run under a non-root user on port 8080. I want to redirect all the packets to port 8080. In certain cases my application itself makes a request to the server from within the server.
Question: Are there any holes in my firewall? Ways I can make this more secure.
Here is my firewall setting:
*filter
:FORWARD ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
:OUTPUT ACCEPT [0:0]
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p esp -j ACCEPT
-A RH-Firewall-1-INPUT -p ah -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# Allow Secure SSH transfer
-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 22 --state NEW -j ACCEPT
# Allow all HTTP requests
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
*mangle
:FORWARD ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed
*nat
:OUTPUT ACCEPT [0:0]
-A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
# Routes all HTTP requests from port 80 to port 8080.
# Allows you to run JETTY as a non-root user.
-A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
COMMIT
# Completed