This commit is contained in:
Alexey Berezhok
2026-05-11 23:28:47 +03:00
parent adef1a98bb
commit 9d1afcdf28
3 changed files with 38 additions and 11 deletions

View File

@@ -254,7 +254,7 @@ check_result $? "Proxy restart failed" > /dev/null
# Execute bunkerweb_module if it's enabled
module_state=$($BIN/v-ext-modules state bunkerweb_module json | jq -r '.[0].STATE')
if [ "$module_state" = "enabled" ]; then
$BIN/v-ext-modules-run bunkerweb_module add "$domain"
$BIN/v-ext-modules-run bunkerweb_module add "$domain" "$ip"
if [ -n "%$ALIAS" ]; then
$BIN/v-ext-modules-run bunkerweb_module alias "$domain" "$ALIAS"
fi

View File

@@ -7,7 +7,7 @@
# This function enables and disables additional modules
#
# Commands:
# add [domain_name]
# add [domain_name] [ip]
# addssl [domain_name] [SSL_CERT_PATH] [SSL_KEY_PATH]
# delete [domain_name]
# updssl [domain] [SSL_CERT_PATH] [SSL_KEY_PATH]
@@ -59,10 +59,11 @@ case v_command.to_sym
when :add
v_domain = ARGV[1].strip
v_format = ARGV[2] unless ARGV[2].nil?
v_ip = ARGV[2] ? ARGV[2].strip : nil
v_format = ARGV[3] unless ARGV[2].nil?
if v_domain.nil? || v_domain == ""
hestia_print_error_message_to_cli "domain should not be empty"
if v_domain.nil? || v_domain == "" || v_ip.nil? || v_ip == ""
hestia_print_error_message_to_cli "domain and ip should not be empty"
log_event E_ARGS, $ARGUMENTS
exit 1
else
@@ -86,7 +87,7 @@ when :add
end
api.create_service(v_domain, {
ssl: "no",
reverse_proxy_host: "http://127.0.0.1:#{$PROXY_PORT}"
reverse_proxy_host: "http://#{v_ip}:#{$PROXY_PORT}"
})
rescue BunkerWebApiError => e
hestia_print_error_message_to_cli "[ERROR] Ошибка API: #{e.message}"

View File

@@ -52,8 +52,32 @@ SSL_CERT_PATH = ARGV[0] || nil # First argument: SSL certificate path
SSL_KEY_PATH = ARGV[1] || nil # Second argument: SSL key path
# Generate secure passwords (meeting BunkerWeb password policy requirements)
API_PASSWORD = SecureRandom.alphanumeric(24) + "!@#"
ADMIN_PASSWORD = SecureRandom.alphanumeric(24) + "!@#"
api_env_file = "/etc/bunkerweb/api.env"
api_password = nil
if File.exist?(api_env_file)
File.foreach(api_env_file) do |line|
if line =~ /^\s*API_PASSWORD=(.*)/
val = $1.strip
api_password = val unless val.empty?
break
end
end
end
specials = '!@#$%^&*()-_=+[]{}|;:,.<>?'
API_PASSWORD = api_password || (SecureRandom.alphanumeric(24) + specials.chars.sample(3).join).chars.shuffle.join
ui_env_file = "/etc/bunkerweb/ui.env"
admin_password = nil
if File.exist?(ui_env_file)
File.foreach(ui_env_file) do |line|
if line =~ /^\s*ADMIN_PASSWORD=(.*)/
val = $1.strip
admin_password = val unless val.empty?
break
end
end
end
ADMIN_PASSWORD = admin_password || (SecureRandom.alphanumeric(24) + specials.chars.sample(3).join).chars.shuffle.join
puts "[INFO] Get server IP address"
@@ -225,6 +249,8 @@ system("systemctl enable bunkerweb-api")
puts "[INFO] Starting bunkerweb-api service..."
system("systemctl start bunkerweb-api")
sleep(30)
# Wait for the service to be ready (max 30 seconds)
puts "[INFO] Waiting for bunkerweb-api service to be running..."
max_attempts = 60 # Wait up to 30 seconds (check every half second)
@@ -341,7 +367,7 @@ DEFAULT_SERVICES = [
ssl: "no",
reverse_proxy_host: "http://127.0.0.1:7000",
use_template: "ui",
reverse_proxy_url: "/bw",
reverse_proxy_url: "/kormilo",
use_reverse_proxy: "yes"
}
},
@@ -414,9 +440,9 @@ begin
puts ""
puts "Web UI is now accessible at:"
if ui_ssl_enabled == "yes"
puts " https://#{server_ip_addr}/bw"
puts " https://#{server_ip_addr}/kormilo"
else
puts " http://#{server_ip_addr}/bw"
puts " http://#{server_ip_addr}/kormilo"
end
puts ""
puts "API URL: #{API_URL}"