From 6157c69a1a1334db1d1b7b04a4befcf73a5377bb Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 18 Dec 2020 11:34:11 -0800 Subject: [PATCH] Also use th new options to listen on all IPs and support http2 --- virtual_feature.pl | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/virtual_feature.pl b/virtual_feature.pl index 2217d6b..c584273 100644 --- a/virtual_feature.pl +++ b/virtual_feature.pl @@ -223,15 +223,27 @@ sub feature_setup else { push(@sslopts, 'ssl'); } -if (!$old_ip4) { - push(@listen, { 'name' => 'listen', - 'words' => [ $d->{'ip'}.":".$d->{'web_sslport'}, - @sslopts ] }); +push(@sslopts, "http2") if ($virtualmin_nginx::config{'http2'}); +if ($virtualmin_nginx::config{'listen_mode'}) { + # Listen on all IPs + if (!$old_ip4 && !$old_ip6) { + push(@listen, { 'name' => 'listen', + 'words' => [ $d->{'web_sslport'}, + @sslopts ] }); + } } -if (!$old_ip6 && $d->{'ip6'}) { - push(@listen, { 'name' => 'listen', - 'words' => [ "[".$d->{'ip6'}."]:".$d->{'web_sslport'}, - @sslopts ]}); +else { + # Add on specific IPs + if (!$old_ip4) { + push(@listen, { 'name' => 'listen', + 'words' => [ $d->{'ip'}.":".$d->{'web_sslport'}, + @sslopts ] }); + } + if (!$old_ip6 && $d->{'ip6'}) { + push(@listen, { 'name' => 'listen', + 'words' => [ "[".$d->{'ip6'}."]:".$d->{'web_sslport'}, + @sslopts ]}); + } } &virtualmin_nginx::save_directive($server, "listen", \@listen); @@ -292,6 +304,9 @@ sub feature_modify $w[0] =~ s/:\d+$//; $w[0] .= ":".$d->{'web_sslport'}; } + elsif ($w[0] eq $oldd->{'web_sslport'}) { + $w[0] = $d->{'web_sslport'}; + } push(@newlisten, { 'words' => \@w }); } &virtualmin_nginx::save_directive($server, "listen", \@newlisten); @@ -480,6 +495,8 @@ sub feature_validate $d->{'web_sslport'} == 80 || $l =~ /^\Q$d->{'ip'}\E:(\d+)$/ && $d->{'web_sslport'} == $1); + $found++ if ($l eq $d->{'web_sslport'} && + $virtualmin_nginx::config{'listen_mode'}); } $found || return &virtualmin_nginx::text('feat_evalidateip', $d->{'ip'}, $d->{'web_sslport'}); @@ -490,6 +507,8 @@ sub feature_validate $d->{'web_sslport'} == 80 || $l =~ /^\[\Q$d->{'ip6'}\E\]:(\d+)$/ && $d->{'web_sslport'} == $1); + $found6++ if ($l eq $d->{'web_sslport'} && + $virtualmin_nginx::config{'listen_mode'}); } $found6 || return &virtualmin_nginx::text('feat_evalidateip6', $d->{'ip6'}, $d->{'web_sslport'});