From 005e20bef89c6aef8b162ee771b56091713c1197 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Wed, 19 Sep 2018 22:24:35 -0400 Subject: [PATCH] Merge pull request #630 from sdbruder/fix-ngrok-issue fix for share of secured sites --- cli/stubs/secure.valet.conf | 36 ++++++++++++++++++++++++++++++++++++ server.php | 4 ++++ valet | 12 ++++++++---- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/cli/stubs/secure.valet.conf b/cli/stubs/secure.valet.conf index b4f0bd447..c8151247b 100644 --- a/cli/stubs/secure.valet.conf +++ b/cli/stubs/secure.valet.conf @@ -43,3 +43,39 @@ server { deny all; } } + +server { + listen 88; + server_name VALET_SITE www.VALET_SITE *.VALET_SITE; + root /; + charset utf-8; + client_max_body_size 128M; + + location /VALET_STATIC_PREFIX/ { + internal; + alias /; + try_files $uri $uri/; + } + + location / { + rewrite ^ VALET_SERVER_PATH last; + } + + access_log off; + error_log VALET_HOME_PATH/Log/nginx-error.log; + + error_page 404 VALET_SERVER_PATH; + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass unix:VALET_HOME_PATH/valet.sock; + fastcgi_index VALET_SERVER_PATH; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME VALET_SERVER_PATH; + } + + location ~ /\.ht { + deny all; + } +} + diff --git a/server.php b/server.php index 743cff1a9..725112d44 100644 --- a/server.php +++ b/server.php @@ -32,6 +32,10 @@ function valet_support_xip_io($domain) } } + if (strpos($domain, ':') !== false) { + $domain = explode(':',$domain)[0]; + } + return $domain; } diff --git a/valet b/valet index 1a8a510dc..a3ac9620a 100755 --- a/valet +++ b/valet @@ -87,10 +87,14 @@ then fi done - php "$DIR/cli/valet.php" secured "$HOST.$DOMAIN" &> /dev/null || ( - printf "\033[1;31mSecured sites can not be shared.\033[0m\n" - exit 1 - ) + # Decide the correct PORT to use according if the site has a secure + # config or not. + if grep --no-messages --quiet 443 ~/.valet/Nginx/$HOST* + then + PORT=88 + else + PORT=80 + fi # Fetch Ngrok URL In Background... bash "$DIR/cli/scripts/fetch-share-url.sh" &