Skip to content

Instantly share code, notes, and snippets.

@salcode
Last active January 29, 2018 21:53
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salcode/da45f09ca0c319a108db to your computer and use it in GitHub Desktop.
Save salcode/da45f09ca0c319a108db to your computer and use it in GitHub Desktop.
Customfile for VVV to run on host machine IP address
# you can put this file in place by
# navigating to your VVV directory (e.g. `cd ~/vagrant-local`)
# and running
# curl -O https://gist.githubusercontent.com/salcode/da45f09ca0c319a108db/raw/Customfile
# set port forwarding from host 8080 to guest 80
config.vm.network "forwarded_port", guest: 80, host: 8080
if defined? VagrantPlugins::Triggers
# port forwarding setup and removal for running on your host primary IP address
config.trigger.after [:up, :reload, :provision], :stdout => true do
system('echo "
rdr pass on lo0 inet proto tcp from any to self port 80 -> 127.0.0.1 port 8080
rdr pass on en0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass on en1 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
" | sudo pfctl -ef - >/dev/null 2>&1; echo "Add Port Forwarding (80 => 8080)"')
end
config.trigger.after [:halt, :suspend, :destroy], :stdout => true do
system('sudo pfctl -F all -f /etc/pf.conf >/dev/null 2>&1; echo "Removing Port Forwarding (80 => 8080)"')
end
end
@salcode
Copy link
Author

salcode commented Mar 19, 2015

Props to @speakus for condensing three lines into one. Revision made 2015-03-19

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