Exposing port 80 on OSX with VirtualBox

VirtualBox on OSX has that annoying limitation :

Forwarding host ports < 1024 impossible:
 On Unix-based hosts (e.g. Linux, Solaris, Mac OS X) it is not possible to bind to ports below 1024 from applications that are not run by root. As a result, if you try to configure such a port forwarding, the VM will refuse to start.

A quick way to expose a website is to expose the 8080 on the VirtualBox NAT instead as it is above 1024 and it is not a problem, then to redirect the port 80 with the OSX NAT to the port 8080. I can be done simply that way :

echo “
 rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
 “ | sudo pfctl -ef –

You can then disable it with :

sudo pfctl -F all -f /etc/pf.conf