Merge pull request #303 from Churro/froxlorMerge

Nginx: Fix for redundantly inserted auth blocks
This commit is contained in:
Michael Kaufmann
2016-02-21 13:09:29 +01:00

View File

@@ -429,7 +429,7 @@ class nginx extends HttpConfigBase {
if (substr($uri, -1) == '/') {
$uri = substr($uri, 0, -1);
}
$vhost_content .= "\t".'rewrite ^(.*) '.$uri.'$1 permanent;'."\n";
$vhost_content .= "\t".'return 301 '.$uri.'$request_uri;'."\n";
} else {
mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true);
@@ -791,7 +791,18 @@ class nginx extends HttpConfigBase {
$returnval[$x]['path'] = $path;
$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;
$x++;
}