Skip to content

Instantly share code, notes, and snippets.

@pgherveou
Forked from logicalparadox/iptables.rules
Created April 24, 2012 21:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgherveou/2483739 to your computer and use it in GitHub Desktop.
Save pgherveou/2483739 to your computer and use it in GitHub Desktop.
Getting Node.js process to run on port 80 without sudo
# NAT interface routing
*nat
# Setup
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [2:128]
:OUTPUT ACCEPT [2:120]
:POSTROUTING ACCEPT [2:120]
# Redirect port 80 to port 8080
-A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
# Redirect port 443 to port 9090
-A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 9090
# Save
COMMIT
# Filter interface routing
*filter
# Setup
:INPUT ACCEPT [2:128]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [246:28805]
# Allow all internal traffic
-A INPUT -i lo -j ACCEPT
# Accept already established connections
-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
# Our exposed ports
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
# Save
COMMIT
# save to /etc/iptables.rules
# $ sudo iptables-restore < /etc/iptables.rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment