From 3e52274496c0a1b581d156573e60c6885f9a6116 Mon Sep 17 00:00:00 2001 From: Costin Date: Wed, 27 Dec 2017 05:15:16 +0100 Subject: [PATCH] Nginx feature ##subroot for special applications (Magento 2, Laravel etc) --- server/plugins-available/nginx_plugin.inc.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index daf953e265..dd680380c9 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -2863,6 +2863,16 @@ class nginx_plugin { } private function nginx_merge_locations($vhost_conf){ + global $app, $conf; + + if(preg_match('/##subroot (.+) ##/', $vhost_conf, $subroot)) { + if(!preg_match('/^(?:[a-z0-9\/_-]|\.(?!\.))+$/iD', $subroot[1])) { + $app->log('Token ##subroot is unsecure (server ID: '.$conf['server_id'].').', LOGLEVEL_WARN); + } else { + $insert_pos = strpos($vhost_conf, ';', strpos($vhost_conf, 'root ')); + $vhost_conf = substr_replace($vhost_conf, ltrim($subroot[1], '/'), $insert_pos, 0); + } + } $lines = explode("\n", $vhost_conf); -- GitLab