Skip to content

Commit 8b4cc0c

Browse files
author
Marius Burkard
committed
Merge branch 'patch-1' into 'stable-3.1'
Nginx feature ##subroot for special applications (Magento 2, Laravel etc) See merge request ispconfig/ispconfig3!698
2 parents 8f24b1b + 3e52274 commit 8b4cc0c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

server/plugins-available/nginx_plugin.inc.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,6 +2863,16 @@ private function nginx_replace($matches){
28632863
}
28642864

28652865
private function nginx_merge_locations($vhost_conf){
2866+
global $app, $conf;
2867+
2868+
if(preg_match('/##subroot (.+) ##/', $vhost_conf, $subroot)) {
2869+
if(!preg_match('/^(?:[a-z0-9\/_-]|\.(?!\.))+$/iD', $subroot[1])) {
2870+
$app->log('Token ##subroot is unsecure (server ID: '.$conf['server_id'].').', LOGLEVEL_WARN);
2871+
} else {
2872+
$insert_pos = strpos($vhost_conf, ';', strpos($vhost_conf, 'root '));
2873+
$vhost_conf = substr_replace($vhost_conf, ltrim($subroot[1], '/'), $insert_pos, 0);
2874+
}
2875+
}
28662876

28672877
$lines = explode("\n", $vhost_conf);
28682878

0 commit comments

Comments
 (0)