Created
March 20, 2012 23:44
-
-
Save logicalparadox/2142595 to your computer and use it in GitHub Desktop.
Getting Node.js process to run on port 80 without sudo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# save this to /etc/network/if-pre-up.d/iptaload | |
iptables-restore < /etc/iptables.rules | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# save this to /etc/network/if-post-down.d/iptasave | |
iptables-save -c > /etc/iptables.save | |
if [ -f /etc/iptables.downrules ]; then | |
iptables-restore < /etc/iptables.downrules | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also,