Skip to content

Instantly share code, notes, and snippets.

@Tam
Last active May 16, 2019 10:17
Show Gist options
  • Save Tam/5f1e8b7c9e809905f3ab5eef4cd53617 to your computer and use it in GitHub Desktop.
Save Tam/5f1e8b7c9e809905f3ab5eef4cd53617 to your computer and use it in GitHub Desktop.
Craft CMS Ngrok w/ Docker

Ensure your site URL's use @web (I know it's not recommended, but that's the only way I could get it to work). Change it back to $DEFAULT_SITE_URL (or whatever you had before) for production.

ngrok http dev.example.com:443 -host-header=dev.example.com -region=eu
<?php
$isNgrok = array_key_exists('HTTP_X_ORIGINAL_HOST', $_SERVER) && strpos($_SERVER['HTTP_X_ORIGINAL_HOST'], 'ngrok');
$host = $isNgrok ? ('https://' . $_SERVER['HTTP_X_ORIGINAL_HOST'] . '/') : getenv('DEFAULT_SITE_URL');
return [
'*' => [
'siteUrl' => $host,
'aliases' => [
'web' => $host,
],
],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment