mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Add ability to redirect to enforced host
This commit is contained in:
18
miniserv.pl
18
miniserv.pl
@@ -1520,7 +1520,8 @@ if (defined($header{'host'})) {
|
||||
else {
|
||||
$host = $header{'host'};
|
||||
}
|
||||
if ($config{'musthost'} && $host ne $config{'musthost'}) {
|
||||
if ($config{'musthost'} && $host ne $config{'musthost'} &&
|
||||
!$config{'musthost_redirect'}) {
|
||||
# Disallowed hostname used
|
||||
&http_error(400, "Invalid HTTP hostname");
|
||||
}
|
||||
@@ -1543,6 +1544,21 @@ if ($config{'redirect_prefix'}) {
|
||||
}
|
||||
$prot = $ssl ? "https" : "http";
|
||||
|
||||
# Disallowed hostname used by redirecting to musthost
|
||||
if ($config{'musthost'} && $host ne $config{'musthost'} &&
|
||||
$config{'musthost_redirect'}) {
|
||||
&write_data("HTTP/1.0 302 Moved Temporarily\r\n");
|
||||
&write_data("Date: $datestr\r\n");
|
||||
&write_data("Server: @{[&server_info()]}\r\n");
|
||||
&write_data("Location: $prot://$config{'musthost'}:$redirport\r\n");
|
||||
&write_keep_alive(0);
|
||||
&write_data("\r\n");
|
||||
&log_request($loghost, $authuser, $reqline, 302, 0) if $reqline;
|
||||
shutdown(SOCK, 1);
|
||||
close(SOCK);
|
||||
return;
|
||||
}
|
||||
|
||||
undef(%in);
|
||||
if ($page =~ /^([^\?]+)\?(.*)$/) {
|
||||
# There is some query string information
|
||||
|
||||
Reference in New Issue
Block a user