map $http_cookie $devroot {
default "/home/user/sandbox.test.co/public";
"~*devroot=dev1;?.*" "/home/user/dev1.test.co/public";
"~*devroot=dev2;?.*" "/home/user/dev2.test.co/public";
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name sandbox.test.co;
root $devroot;
...Other config...
location ~ \/dev\/([^\/]+)\/on {
add_header Set-Cookie "devroot=$1;Path=/;";
return 201 "$1 created";
default_type text/plain;
}
location ~ \/dev\/([^\/]+)\/off {
add_header Set-Cookie "devroot=;Path=/;";
return 200 "$1 deleted";
default_type text/plain;
}
...Other config...
# SET: https://${domain}/dev/${NAME}/on
# UNSET: https://${domain}/dev/${NAME}/off
}
Laravel, "SANDBOX ON DEV: " badge will be displayed on top of the web page.
@if (config('app.env' ) !== 'production' && $ _COOKIE ['devroot' ] ?? null )
<div class="fixed-top ">
<span class="badge badge-warning text-uppercase px-2 py-2 h3 " style="opacity: 0.5 ;">
Sandbox On DEV: { {$ _COOKIE ['devroot' ] ?? null }}
</span>
</div>
@endif