mirror of
https://github.com/webmin/webmin.git
synced 2026-05-06 15:20:29 +01:00
Fix to gate forwarded proxy URL for consistency
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
https://github.com/webmin/webmin/pull/2666#issuecomment-4241962133
This commit is contained in:
14
miniserv.pl
14
miniserv.pl
@@ -5909,12 +5909,14 @@ my $add_origin = sub {
|
||||
&$add_origin(&normalise_websocket_origin($prot, $redirhost, $redirport));
|
||||
|
||||
# Reverse proxy headers, when present
|
||||
&$add_origin(&forwarded_websocket_origin($header{'x-forwarded-proto'},
|
||||
$header{'x-forwarded-host'},
|
||||
$header{'x-forwarded-port'}));
|
||||
&$add_origin(&forwarded_websocket_origin($header{'x-forwarded-proto'},
|
||||
$header{'host'},
|
||||
$header{'x-forwarded-port'}));
|
||||
if ($config{'trust_real_ip'}) {
|
||||
&$add_origin(&forwarded_websocket_origin($header{'x-forwarded-proto'},
|
||||
$header{'x-forwarded-host'},
|
||||
$header{'x-forwarded-port'}));
|
||||
&$add_origin(&forwarded_websocket_origin($header{'x-forwarded-proto'},
|
||||
$header{'host'},
|
||||
$header{'x-forwarded-port'}));
|
||||
}
|
||||
|
||||
# Explicit websocket host setting, converted back to a page origin
|
||||
if ($config{'websocket_host'}) {
|
||||
|
||||
@@ -14282,6 +14282,7 @@ my $ws_proto = lc($ENV{'HTTPS'}) eq 'on' ? 'wss' : 'ws';
|
||||
my %miniserv;
|
||||
my $webprefix = &get_webprefix();
|
||||
&get_miniserv_config(\%miniserv);
|
||||
my $trust_proxy = $miniserv{'trust_real_ip'};
|
||||
my $wspath = "/$module/ws-".$port;
|
||||
my $wstoken;
|
||||
if ($miniserv{'websockets_'.$wspath} &&
|
||||
@@ -14297,7 +14298,7 @@ if ($http_host_conf) {
|
||||
$http_host_conf =~ s/[\/]+$//g;
|
||||
}
|
||||
# Try to rely on the proxy
|
||||
if (!defined($http_host_conf)) {
|
||||
if ($trust_proxy && !defined($http_host_conf)) {
|
||||
my $forwarded_host = $ENV{'HTTP_X_FORWARDED_HOST'};
|
||||
if ($forwarded_host) {
|
||||
$http_host_conf = "$ws_proto://$forwarded_host";
|
||||
|
||||
Reference in New Issue
Block a user