diff --git a/usermin/change_bind.cgi b/usermin/change_bind.cgi
index 3a5dc0f4b..b397107f4 100755
--- a/usermin/change_bind.cgi
+++ b/usermin/change_bind.cgi
@@ -64,6 +64,18 @@ else {
$miniserv{'bind'} = $first->[0];
}
$miniserv{'sockets'} = join(" ", map { "$_->[0]:$_->[1]" } @sockets);
+if ($in{'websocket_base_port_def'}) {
+ delete($miniserv{'websocket_base_port'});
+ }
+else {
+ $miniserv{'websocket_base_port'} = $in{'websocket_base_port'};
+ }
+if ($in{'websocket_host_def'}) {
+ delete($miniserv{'websocket_host'});
+ }
+else {
+ $miniserv{'websocket_host'} = $in{'websocket_host'};
+ }
$miniserv{'ipv6'} = $in{'ipv6'};
if ($in{'listen_def'}) {
delete($miniserv{'listen'});
diff --git a/usermin/edit_bind.cgi b/usermin/edit_bind.cgi
index fcec8e659..5f6fb1d42 100755
--- a/usermin/edit_bind.cgi
+++ b/usermin/edit_bind.cgi
@@ -47,6 +47,22 @@ if (&foreign_check("firewall")) {
}
print &ui_table_row($text{'bind_sockets'}, $stable);
+# WebSocket based port
+print &ui_table_row($text{'bind_websocport'},
+ &ui_radio("websocket_base_port_def",
+ $miniserv{"websocket_base_port"} ? 0 : 1,
+ [ [ 1, $text{'bind_websocport_none'} ],
+ [ 0, &ui_textbox("websocket_base_port",
+ $miniserv{"websocket_base_port"}, 6) ] ]));
+
+# Hostname for WebSocket connections
+print &ui_table_row($text{'bind_websoc_host'},
+ &ui_radio("websocket_host_def",
+ $miniserv{"websocket_host"} ? 0 : 1,
+ [ [ 1, $text{'bind_websoc_host_auto'} ],
+ [ 0, &ui_textbox("websocket_host",
+ $miniserv{"websocket_host"}, 25) ] ]));
+
# IPv6 enabled?
print &ui_table_row($text{'bind_ipv6'},
&ui_yesno_radio("ipv6", $miniserv{'ipv6'}));
diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl
index 81792f947..a528338a9 100755
--- a/web-lib-funcs.pl
+++ b/web-lib-funcs.pl
@@ -13539,7 +13539,7 @@ foreach my $k (keys %miniserv) {
}
# Pick a port and configure Webmin to proxy it
-my $port = $config{'base_port'} || 555;
+my $port = $miniserv{'websocket_base_port'} || 555;
while(1) {
if (!$inuse{$port}) {
&open_socket("127.0.0.1", $port, my $fh, \$err);
diff --git a/webmin/change_bind.cgi b/webmin/change_bind.cgi
index e784b581a..f5592abe6 100755
--- a/webmin/change_bind.cgi
+++ b/webmin/change_bind.cgi
@@ -84,6 +84,18 @@ else {
$miniserv{'bind'} = $first->[0];
}
$miniserv{'sockets'} = join(" ", map { "$_->[0]:$_->[1]" } @sockets);
+if ($in{'websocket_base_port_def'}) {
+ delete($miniserv{'websocket_base_port'});
+ }
+else {
+ $miniserv{'websocket_base_port'} = $in{'websocket_base_port'};
+ }
+if ($in{'websocket_host_def'}) {
+ delete($miniserv{'websocket_host'});
+ }
+else {
+ $miniserv{'websocket_host'} = $in{'websocket_host'};
+ }
$miniserv{'ipv6'} = $in{'ipv6'};
if ($in{'listen_def'}) {
delete($miniserv{'listen'});
diff --git a/webmin/edit_bind.cgi b/webmin/edit_bind.cgi
index c1daf86ec..1124910f7 100755
--- a/webmin/edit_bind.cgi
+++ b/webmin/edit_bind.cgi
@@ -44,6 +44,22 @@ if (&foreign_check("firewall")) {
}
print &ui_table_row($text{'bind_sockets'}, $stable);
+# WebSocket based port
+print &ui_table_row($text{'bind_websocport'},
+ &ui_radio("websocket_base_port_def",
+ $miniserv{"websocket_base_port"} ? 0 : 1,
+ [ [ 1, $text{'bind_websocport_none'} ],
+ [ 0, &ui_textbox("websocket_base_port",
+ $miniserv{"websocket_base_port"}, 6) ] ]));
+
+# Hostname for WebSocket connections
+print &ui_table_row($text{'bind_websoc_host'},
+ &ui_radio("websocket_host_def",
+ $miniserv{"websocket_host"} ? 0 : 1,
+ [ [ 1, $text{'bind_websoc_host_auto'} ],
+ [ 0, &ui_textbox("websocket_host",
+ $miniserv{"websocket_host"}, 25) ] ]));
+
# IPv6 enabled?
print &ui_table_row($text{'bind_ipv6'},
&ui_yesno_radio("ipv6", $miniserv{'ipv6'}));
diff --git a/webmin/lang/en b/webmin/lang/en
index 8bff00870..41a37e36c 100644
--- a/webmin/lang/en
+++ b/webmin/lang/en
@@ -46,6 +46,10 @@ bind_sport0=Same as first
bind_sport1=Specific port ..
bind_listen=Listen for broadcasts on UDP port
bind_none=Don't listen
+bind_websocport=Base port number for WebSockets connections
+bind_websocport_none=Default (555)
+bind_websoc_host=Hostname for WebSocket connections
+bind_websoc_host_auto=Automatic
bind_hostname=Web server hostname
bind_auto=Work out from browser
bind_err=Failed to change address
diff --git a/xterm/config.info b/xterm/config.info
index 1af788a51..6d098b138 100644
--- a/xterm/config.info
+++ b/xterm/config.info
@@ -1,6 +1,4 @@
xterm=Set TERM environmental variable to,4,xterm+256color-xterm-256color,xterm+16color-xterm-16color,xterm-xterm,vt102-vt102,vt100-vt100,vt52-vt52,rxvt-rxvt,nsterm-nsterm,dtterm-dtterm,ansi-ansi
-base_port=Base port number for WebSockets connections,0,5
-host=Hostname for WebSocket connections,3,Automatic,32,,,Manual
size=Terminal width and height in characters,3,Automatic,5,,,Static (80x24)
locale=Set shell character encoding,10,0-Shell default,1-en_US.UTF-8,Custom
rcfile=Execute initialization commands from file,10,0-Shell default,1-Module default,Custom
diff --git a/xterm/index.cgi b/xterm/index.cgi
index e6f619e24..87b18750d 100755
--- a/xterm/index.cgi
+++ b/xterm/index.cgi
@@ -201,7 +201,9 @@ $ENV{'SESSION_ID'} = $main::session_id;
# Open the terminal
my $ws_proto = lc($ENV{'HTTPS'}) eq 'on' ? 'wss' : 'ws';
-my $http_host_conf = &trim($config{'host'});
+my %miniserv;
+&get_miniserv_config(\%miniserv);
+my $http_host_conf = &trim($miniserv{'websocket_host'} || $config{'host'});
if ($http_host_conf) {
if ($http_host_conf !~ /^wss?:\/\//) {
$http_host_conf = "$ws_proto://$http_host_conf";