Nginx: Fix for redundantly inserted auth blocks

The problem occurs if a Vhost is assigned multiple different auth names
in Froxlor. Each block is then added repeatedly, leading to an
unparseable configuration
This commit is contained in:
Johannes Feichtner
2015-09-15 23:33:40 +02:00
parent 1c4b88d014
commit 3b9201fb91

View File

@@ -788,7 +788,18 @@ class nginx extends HttpConfigBase {
$returnval[$x]['path'] = $path; $returnval[$x]['path'] = $path;
$returnval[$x]['root'] = makeCorrectDir($domain['documentroot']); $returnval[$x]['root'] = makeCorrectDir($domain['documentroot']);
$returnval[$x]['authname'] = $row_htpasswds['authname'];
// Ensure there is only one auth name per password block, otherwise
// the directives are inserted multiple times -> invalid config
$authname = $row_htpasswds['authname'];
for ($i = 0; $i < $x; $i++) {
if ($returnval[$i]['usrf'] == $htpasswd_filename) {
$authname = $returnval[$i]['authname'];
break;
}
}
$returnval[$x]['authname'] = $authname;
$returnval[$x]['usrf'] = $htpasswd_filename; $returnval[$x]['usrf'] = $htpasswd_filename;
$x++; $x++;
} }