Skip to content

Instantly share code, notes, and snippets.

@calimaborges
Last active December 19, 2015 13:59
Show Gist options
  • Save calimaborges/5966049 to your computer and use it in GitHub Desktop.
Save calimaborges/5966049 to your computer and use it in GitHub Desktop.
Configuring vagrant to redirect 80 to 8080

Vagrant pre config

Source: http://wiki.debian.org/Firewalls-local-port-redirection

Clear iptables rules (not necessary, just in case)

# 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

Config to redirect from 80 to 8080 (locally)

# iptables -t nat -I OUTPUT --src 0/0 --dst 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 8080

Config to redirect from 80 to 8080 (externally)

# iptables -t nat -I PREROUTING --src 0/0 --dst 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports 8080

Save and restore iptables rules

# iptables-save > arquivo
# iptables-restore < arquivo

Mais sobre: http://askubuntu.com/questions/66890/how-can-i-make-a-specific-set-of-iptables-rules-permanent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment