From ac7b371d49862284dd7c2b9dcbd85d01d401e00a Mon Sep 17 00:00:00 2001 From: Sergio Bruder Date: Fri, 14 Sep 2018 03:39:33 -0300 Subject: [PATCH] fix for share of secured sites --- cli/stubs/secure.valet.conf | 36 ++++++++++++++++++++++++++++++++++++ valet | 15 ++++++++++++--- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/cli/stubs/secure.valet.conf b/cli/stubs/secure.valet.conf index 8471a82..a875a9f 100644 --- a/cli/stubs/secure.valet.conf +++ b/cli/stubs/secure.valet.conf @@ -41,3 +41,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/valet b/valet index 9a4af1b..2b4e9e6 100755 --- a/valet +++ b/valet @@ -41,9 +41,18 @@ then fi done - # Fetch Ngrok URL In Background... - bash "$DIR/cli/scripts/fetch-share-url.sh" & - sudo -u $(logname) "$DIR/bin/ngrok" http "$HOST.$TLD:80" -host-header=rewrite ${*:2} + # Decide the correct PORT to use according if the site has a secure + # config or not. + if grep 443 "~/.config/valet/Nginx/$HOST*" + then + PORT=88 + else + PORT=80 + fi + + # Fetch Ngrok URL In Background... + bash "$DIR/cli/scripts/fetch-share-url.sh" & + sudo -u $(logname) "$DIR/bin/ngrok" http "$HOST.$TLD:$PORT" -host-header=rewrite ${*:2} exit # Finally, for every other command we will just proxy into the PHP tool