Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow secured sites to be shared #181

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions cli/stubs/secure.valet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

4 changes: 4 additions & 0 deletions server.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ function valet_support_xip_io($domain)
}
}

if (strpos($domain, ':') !== false) {
$domain = explode(':',$domain)[0];
}

return $domain;
}

Expand Down
12 changes: 8 additions & 4 deletions valet
Original file line number Diff line number Diff line change
Expand Up @@ -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" &
Expand Down