@@ -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 }
0 commit comments