Skip to content

Commit 9b16a37

Browse files
committed
- nginx: merge function: default action is now to replace older locations in the nginx vhost configuration; a merge instead of a replacement can be achieved by putting the string "##merge##" (without quotes) at the end of the most recent location line (e.g. "location ~ \.php$ { ##merge##").
1 parent 2655f93 commit 9b16a37

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

server/conf/nginx_vhost.conf.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ server {
118118
</tmpl_loop>
119119

120120
<tmpl_loop name="basic_auth_locations">
121-
location <tmpl_var name='htpasswd_location'> {
121+
location <tmpl_var name='htpasswd_location'> { ##merge##
122122
auth_basic "Members Only";
123123
auth_basic_user_file <tmpl_var name='htpasswd_path'>.htpasswd;
124124
}

server/plugins-available/nginx_plugin.inc.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,10 +1629,16 @@ private function nginx_merge_locations($vhost_conf){
16291629
}
16301630
unset($loc_parts);
16311631

1632+
if(!isset($locations[$location]['action'])) $locations[$location]['action'] = 'replace';
1633+
if(substr($l, -9) == '##merge##'){
1634+
$locations[$location]['action'] = 'merge';
1635+
}
1636+
16321637
if(!isset($locations[$location]['open_tag'])) $locations[$location]['open_tag'] = ' location '.$location.' {';
1633-
if(!isset($locations[$location]['location'])) $locations[$location]['location'] = '';
1638+
if(!isset($locations[$location]['location']) || $locations[$location]['action'] == 'replace') $locations[$location]['location'] = '';
16341639
if(!isset($locations[$location]['end_tag'])) $locations[$location]['end_tag'] = ' }';
16351640
if(!isset($locations[$location]['start_line'])) $locations[$location]['start_line'] = $i;
1641+
16361642
unset($lines[$i]);
16371643

16381644
} else {

0 commit comments

Comments
 (0)