Skip to content

Commit da8798a

Browse files
author
Andreas Palm
committed
use new options in apache2 and nginx plugins #6477
1 parent 1d5d2fd commit da8798a

File tree

3 files changed

+51
-25
lines changed

3 files changed

+51
-25
lines changed

server/conf/nginx_vhost.conf.master

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ server {
77
</tmpl_if>
88
<tmpl_if name='ipv6_enabled'>
99
listen [<tmpl_var name='ipv6_address'>]:<tmpl_var name='http_port'>;
10+
<tmpl_if name='use_proxy_protocol_ipv6' op='==' value='y'>
11+
<tmpl_if name='proxy_protocol_http' op='>' value='0'>
12+
listen [<tmpl_var name='ipv6_address'>]:<tmpl_var name='proxy_protocol_http'> proxy_protocol;
13+
</tmpl_if>
14+
</tmpl_if>
1015
</tmpl_if>
1116
<tmpl_if name='ipv6_wildcard'>
1217
listen [::]:<tmpl_var name='http_port'>;
@@ -28,6 +33,11 @@ server {
2833
# ssl_prefer_server_ciphers on;
2934
<tmpl_if name='ipv6_enabled'>
3035
listen [<tmpl_var name='ipv6_address'>]:<tmpl_var name='https_port'> ssl http2;
36+
<tmpl_if name='use_proxy_protocol_ipv6' op='==' value='y'>
37+
<tmpl_if name='proxy_protocol_https' op='>' value='0'>
38+
listen [<tmpl_var name='ipv6_address'>]:<tmpl_var name='proxy_protocol_https'> ssl http2 proxy_protocol;
39+
</tmpl_if>
40+
</tmpl_if>
3141
</tmpl_if>
3242
<tmpl_if name='ipv6_wildcard'>
3343
listen [::]:<tmpl_var name='https_port'> ssl http2;

server/plugins-available/apache2_plugin.inc.php

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,13 @@ function update($event_name, $data) {
17731773

17741774
//* create empty vhost array
17751775
$vhosts = array();
1776+
$proxy_protocol_protocols = explode(',', $web_config['vhost_proxy_protocol_protocols']);
1777+
$proxy_protocol_ipv4 = in_array('ipv4', $proxy_protocol_protocols);
1778+
$proxy_protocol_ipv6 = in_array('ipv6', $proxy_protocol_protocols);
1779+
$proxy_protocol_site = $web_config['vhost_proxy_protocol_enabled'] == 'all';
1780+
$proxy_protocol_site |= $web_config['vhost_proxy_protocol_enabled'] == 'y' && $data['new']['proxy_protocol'] == 'y';
1781+
$proxy_protocol_http_port = isset($web_config['vhost_proxy_protocol_http_port']) ? (int)$web_config['vhost_proxy_protocol_http_port'] : 0;
1782+
$proxy_protocol_https_port = isset($web_config['vhost_proxy_protocol_https_port']) ? (int)$web_config['vhost_proxy_protocol_https_port'] : 0;
17761783

17771784
//* Add vhost for ipv4 IP
17781785

@@ -1789,13 +1796,11 @@ function update($event_name, $data) {
17891796
if(count($alias_seo_redirects) > 0) $tmp_vhost_arr = $tmp_vhost_arr + array('alias_seo_redirects' => $alias_seo_redirects);
17901797
$vhosts[] = $tmp_vhost_arr;
17911798

1792-
//if proxy protocol is enabled we need to add a new port to lsiten to
1793-
if($web_config['vhost_proxy_protocol_enabled'] == 'y' && $data['new']['proxy_protocol'] == 'y'){
1794-
if(isset($web_config['vhost_proxy_protocol_http_port']) && (int)$web_config['vhost_proxy_protocol_http_port'] > 0) {
1795-
$tmp_vhost_arr['port'] = (int)$web_config['vhost_proxy_protocol_http_port'];
1796-
$tmp_vhost_arr['use_proxy_protocol'] = $data['new']['proxy_protocol'];
1797-
$vhosts[] = $tmp_vhost_arr;
1798-
}
1799+
//if proxy protocol is enabled we need to add a new port to listen to
1800+
if ($proxy_protocol_site && $proxy_protocol_ipv4 && $proxy_protocol_http_port > 0) {
1801+
$tmp_vhost_arr['port'] = $proxy_protocol_http_port;
1802+
$tmp_vhost_arr['use_proxy_protocol'] = 'y';
1803+
$vhosts[] = $tmp_vhost_arr;
17991804
}
18001805

18011806
unset($tmp_vhost_arr);
@@ -1813,13 +1818,11 @@ function update($event_name, $data) {
18131818
if(count($ipv4_ssl_alias_seo_redirects) > 0) $tmp_vhost_arr = $tmp_vhost_arr + array('alias_seo_redirects' => $ipv4_ssl_alias_seo_redirects);
18141819
$vhosts[] = $tmp_vhost_arr;
18151820

1816-
//if proxy protocol is enabled we need to add a new port to lsiten to
1817-
if($web_config['vhost_proxy_protocol_enabled'] == 'y' && $data['new']['proxy_protocol'] == 'y'){
1818-
if((int)$web_config['vhost_proxy_protocol_https_port'] > 0) {
1819-
$tmp_vhost_arr['port'] = (int)$web_config['vhost_proxy_protocol_https_port'];
1820-
$tmp_vhost_arr['use_proxy_protocol'] = $data['new']['proxy_protocol'];
1821-
$vhosts[] = $tmp_vhost_arr;
1822-
}
1821+
//if proxy protocol is enabled we need to add a new port to listen to
1822+
if ($proxy_protocol_site && $proxy_protocol_ipv4 && $proxy_protocol_https_port > 0) {
1823+
$tmp_vhost_arr['port'] = $proxy_protocol_https_port;
1824+
$tmp_vhost_arr['use_proxy_protocol'] = 'y';
1825+
$vhosts[] = $tmp_vhost_arr;
18231826
}
18241827

18251828
unset($tmp_vhost_arr, $ipv4_ssl_alias_seo_redirects);
@@ -1845,6 +1848,13 @@ function update($event_name, $data) {
18451848
if(count($rewrite_rules) > 0) $tmp_vhost_arr = $tmp_vhost_arr + array('redirects' => $rewrite_rules);
18461849
if(count($alias_seo_redirects) > 0) $tmp_vhost_arr = $tmp_vhost_arr + array('alias_seo_redirects' => $alias_seo_redirects);
18471850
$vhosts[] = $tmp_vhost_arr;
1851+
1852+
//if proxy protocol is enabled we need to add a new port to listen to
1853+
if ($proxy_protocol_site && $proxy_protocol_ipv6 && $proxy_protocol_http_port > 0) {
1854+
$tmp_vhost_arr['port'] = $proxy_protocol_http_port;
1855+
$tmp_vhost_arr['use_proxy_protocol'] = 'y';
1856+
$vhosts[] = $tmp_vhost_arr;
1857+
}
18481858
unset($tmp_vhost_arr);
18491859

18501860
//* Add vhost for ipv6 IP with SSL
@@ -1859,6 +1869,14 @@ function update($event_name, $data) {
18591869
}
18601870
if(count($ipv6_ssl_alias_seo_redirects) > 0) $tmp_vhost_arr = $tmp_vhost_arr + array('alias_seo_redirects' => $ipv6_ssl_alias_seo_redirects);
18611871
$vhosts[] = $tmp_vhost_arr;
1872+
1873+
//if proxy protocol is enabled we need to add a new port to listen to
1874+
if ($proxy_protocol_site && $proxy_protocol_ipv6 && $proxy_protocol_https_port > 0) {
1875+
$tmp_vhost_arr['port'] = $proxy_protocol_https_port;
1876+
$tmp_vhost_arr['use_proxy_protocol'] = 'y';
1877+
$vhosts[] = $tmp_vhost_arr;
1878+
}
1879+
18621880
unset($tmp_vhost_arr, $ipv6_ssl_alias_seo_redirects);
18631881
$app->log('Enable SSL for IPv6: '.$domain, LOGLEVEL_DEBUG);
18641882
}

server/plugins-available/nginx_plugin.inc.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,17 +1599,15 @@ function update($event_name, $data) {
15991599
}
16001600

16011601
//proxy protocol settings
1602-
if($web_config['vhost_proxy_protocol_enabled'] == "y"){
1603-
if((int)$web_config['vhost_proxy_protocol_https_port'] > 0) {
1604-
$vhost_data['use_proxy_protocol'] = $data['new']['proxy_protocol'];
1605-
$vhost_data['proxy_protocol_http'] = (int)$web_config['vhost_proxy_protocol_http_port'];
1606-
$vhost_data['proxy_protocol_https'] = (int)$web_config['vhost_proxy_protocol_https_port'];
1607-
} else {
1608-
$vhost_data['use_proxy_protocol'] = "n";
1609-
}
1610-
}else{
1611-
$vhost_data['use_proxy_protocol'] = "n";
1612-
}
1602+
$proxy_protocol_protocols = explode(',', $web_config['vhost_proxy_protocol_protocols']);
1603+
$proxy_protocol_ipv4 = in_array('ipv4', $proxy_protocol_protocols);
1604+
$proxy_protocol_ipv6 = in_array('ipv6', $proxy_protocol_protocols);
1605+
$proxy_protocol_site = $web_config['vhost_proxy_protocol_enabled'] == 'all';
1606+
$proxy_protocol_site |= $web_config['vhost_proxy_protocol_enabled'] == 'y' && $data['new']['proxy_protocol'] == 'y';
1607+
$vhost_data['proxy_protocol_http'] = isset($web_config['vhost_proxy_protocol_http_port']) ? (int)$web_config['vhost_proxy_protocol_http_port'] : 0;
1608+
$vhost_data['proxy_protocol_https'] = isset($web_config['vhost_proxy_protocol_https_port']) ? (int)$web_config['vhost_proxy_protocol_https_port'] : 0;
1609+
$vhost_data['use_proxy_protocol'] = ($proxy_protocol_site && $proxy_protocol_ipv4) ? 'y' : 'n';
1610+
$vhost_data['use_proxy_protocol_ipv6'] = ($proxy_protocol_site && $proxy_protocol_ipv6) ? 'y' : 'n';
16131611

16141612
// set logging variable
16151613
$vhost_data['logging'] = $web_config['logging'];

0 commit comments

Comments
 (0)