Skip to content

Instantly share code, notes, and snippets.

@jgraup
Created July 15, 2017 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgraup/cf372a7b3143f331cdfbef7cfb4a9b74 to your computer and use it in GitHub Desktop.
Save jgraup/cf372a7b3143f331cdfbef7cfb4a9b74 to your computer and use it in GitHub Desktop.
ngrok with local Vagrant WordPresss site
# site.dev is the name of your hostname
HOST="site.dev";
PORT=80;
IP="$(vagrant ssh -- -t 'ip address show eth1 | grep "inet " | sed -e "s/^.*inet //" -e "s/\/.*$//" | tr -d "\n" | tr -d "\r"; ')";
echo -e "\nHOST:\t$HOST\nIP:\t$IP\nPORT:\t$PORT\n\tStarting ngrok "`date +%Y-%m-%d\ %H:%M:%S`... and opening http://127.0.0.1:4040/"\n";
open http://127.0.0.1:4040;
ngrok http -host-header=$HOST $IP:$PORT
// Add to wp-config.php - change site.dev to your hostname
// Convert all site URLs to relative links in PHP output
ob_start( function( $string ) {
$host = "site.dev";
return preg_replace( '/(http(?:s)?:\/\/)?(' . $host . ')(\/)?/mi', '/', $string );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment