Server IP : 195.201.23.43 / Your IP : 13.59.203.127 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/virtual-server/ |
Upload File : |
#!/usr/bin/perl # Create, update or delete a proxy balancer require './virtual-server-lib.pl'; &ReadParse(); $d = &get_domain($in{'dom'}); &can_edit_domain($d) && &can_edit_forward() || &error($text{'balancers_ecannot'}); $has = &has_proxy_balancer($d); $has || &error($text{'balancers_esupport'}); &error_setup($text{'balancer_err'}); if (!$in{'new'}) { ($b) = grep { $_->{'path'} eq $in{'old'} } &list_proxy_balancers($d); $b || &error($text{'balancer_egone'}); $oldb = { %$b }; } &obtain_lock_web($d); if ($in{'delete'}) { # Just delete it $err = &delete_proxy_balancer($d, $b); &error($err) if ($err); } else { # Validate inputs $in{'path'} =~ /^\/\S*$/ || &error($text{'balancer_epath'}); if ($in{'new'}) { if ($has == 1) { # Doesn't support balancers $b = { }; } elsif ($in{'none'}) { # In no-proxy mode, we don't need balancing $b = { }; } elsif ($in{'balancer_def'}) { # Choose name automatically $in{'path'} =~ /^\/(\S*)$/; $b = { 'balancer' => $1 || "root" }; } else { # Use entered name $in{'balancer'} =~ /^[a-z0-9\_]+$/i || &error($text{'balancer_ebalancer'}); $b = { 'balancer' => $in{'balancer'} }; } } $b->{'path'} = $in{'path'}; if ($in{'none'}) { # Not proxying anywhere $b->{'none'} = 1; } elsif ($in{'new'} && $has == 2 || !$in{'new'} && $b->{'balancer'}) { # Many URLs @urls = grep { /\S/ } split(/\r?\n/, $in{'urls'}); foreach my $u (@urls) { $u =~ /^(http|https):\/\/(\S+)$/ || &error(&text('balancer_eurl', $u)); } @urls || &error($text{'balancer_eurls'}); $b->{'urls'} = \@urls; $b->{'none'} = 0; } else { # One URL $in{'urls'} =~ /^(http|https):\/\/(\S+)$/ || &error($text{'balancer_eurl2'}); $b->{'urls'} = [ $in{'urls'} ]; $b->{'none'} = 0; } # Create or update if ($in{'new'}) { $err = &create_proxy_balancer($d, $b); } else { $err = &modify_proxy_balancer($d, $b, $oldb); } &error($err) if ($err); } # Restart Apache and log &release_lock_web($d); &set_all_null_print(); &run_post_actions(); &webmin_log($in{'new'} ? 'create' : $in{'delete'} ? 'delete' : 'modify', "balancer", $b->{'path'}, { 'dom' => $d->{'dom'} }); &redirect("list_balancers.cgi?dom=$in{'dom'}");Private