From adbc4bc4022eeae900de8d4bf4484e325211e5c8 Mon Sep 17 00:00:00 2001 From: Churro Date: Mon, 1 Dec 2014 22:48:54 +0100 Subject: [PATCH 1/2] Basic auth realms now work for Nginx Vhosts too --- scripts/jobs/cron_tasks.inc.http.30.nginx.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index a61e41a6..56466821 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -619,7 +619,7 @@ class nginx { break; default: if ($single['path'] == '/') { - $path_options .= "\t\t" . 'auth_basic "Restricted Area";' . "\n"; + $path_options .= "\t\t" . 'auth_basic "' . $single['authname'] . '";' . "\n"; $path_options .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n"; // remove already used entries so we do not have doubles unset($htpasswds[$idx]); @@ -679,7 +679,7 @@ class nginx { break; default: $path_options .= "\t" . 'location ' . makeCorrectDir($single['path']) . ' {' . "\n"; - $path_options .= "\t\t" . 'auth_basic "Restricted Area";' . "\n"; + $path_options .= "\t\t" . 'auth_basic "' . $single['authname'] . '";' . "\n"; $path_options .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n"; $path_options .= "\t".'}' . "\n"; } @@ -728,6 +728,7 @@ class nginx { $returnval[$x]['path'] = $path; $returnval[$x]['root'] = makeCorrectDir($domain['documentroot']); + $returnval[$x]['authname'] = $row_htpasswds['authname']; $returnval[$x]['usrf'] = $htpasswd_filename; $x++; } @@ -819,7 +820,7 @@ class nginx { } $stats_text .= "\t\t" . 'alias ' . $alias_dir . ';' . "\n"; - $stats_text .= "\t\t" . 'auth_basic "Restricted Area";' . "\n"; + $stats_text .= "\t\t" . 'auth_basic "' . $single['authname'] . '";' . "\n"; $stats_text .= "\t\t" . 'auth_basic_user_file ' . makeCorrectFile($single['usrf']) . ';'."\n"; $stats_text .= "\t" . '}' . "\n\n"; From 8842c02136df64a68141d95292d0f6791f1754b9 Mon Sep 17 00:00:00 2001 From: Churro Date: Mon, 1 Dec 2014 22:50:07 +0100 Subject: [PATCH 2/2] Fixed indentation of location-block in Nginx Vhosts --- scripts/jobs/cron_tasks.inc.http.30.nginx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index 56466821..0c06ab1f 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -419,7 +419,7 @@ class nginx { ) { $vhost_content.= $this->composeSslSettings($domain); } - $vhost_content = $this->mergeVhostCustom($vhost_content, $this->create_pathOptions($domain)); + $vhost_content = $this->mergeVhostCustom($vhost_content, $this->create_pathOptions($domain)) . "\n"; $vhost_content.= $this->composePhpOptions($domain, $ssl_vhost); $vhost_content.= isset($this->needed_htpasswds[$domain['id']]) ? $this->needed_htpasswds[$domain['id']] . "\n" : '';