Fix setting webprefix for WebSocket URL

https://forum.virtualmin.com/t/after-update-webmin-2-200-cant-view-stat-history/128119/6?u=ilia
This commit is contained in:
Ilia Ross
2024-07-26 00:41:40 +03:00
parent 0247b71fb7
commit 253d85b6ee

View File

@@ -13718,6 +13718,7 @@ my ($port, $host, $module) = @_;
$module ||= $module_name;
my $ws_proto = lc($ENV{'HTTPS'}) eq 'on' ? 'wss' : 'ws';
my %miniserv;
my $webprefix = &get_webprefix();
&get_miniserv_config(\%miniserv);
my $http_host_conf = &trim($miniserv{'websocket_host'} || $host);
# Pass as defined
@@ -13731,12 +13732,12 @@ if ($http_host_conf) {
if (!defined($http_host_conf)) {
my $forwarded_host = $ENV{'HTTP_X_FORWARDED_HOST'};
if ($forwarded_host) {
$http_host_conf = "$ws_proto://$forwarded_host".
&get_webprefix();
$http_host_conf =~ s/\/$//;
$http_host_conf = "$ws_proto://$forwarded_host";
$http_host_conf =~ s/[\/]+$//g;
}
}
my $http_host = $http_host_conf || "$ws_proto://$ENV{'HTTP_HOST'}";
$http_host .= $webprefix if ($webprefix);
return "$http_host/$module/ws-$port";
}