From 253d85b6ee6e448ec0ea2a45b6ca2e6d0bd736a1 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 26 Jul 2024 00:41:40 +0300 Subject: [PATCH] Fix setting webprefix for WebSocket URL https://forum.virtualmin.com/t/after-update-webmin-2-200-cant-view-stat-history/128119/6?u=ilia --- web-lib-funcs.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 53f20e1a6..c61322f7f 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -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"; }