diff --git a/modules/performance/nginx-varnish-manager.sh b/modules/performance/nginx-varnish-manager.sh index 0a66b5f..52d0c32 100755 --- a/modules/performance/nginx-varnish-manager.sh +++ b/modules/performance/nginx-varnish-manager.sh @@ -477,13 +477,22 @@ install_varnish() { configure_varnish_vcl() { print_banner "Configuring Varnish VCL" + # Get server's primary IP address for Apache backend + local server_ip=$(hostname -I | awk '{print $1}') + if [ -z "$server_ip" ]; then + server_ip="127.0.0.1" + print_warning "Could not detect server IP, using 127.0.0.1" + else + print_info "Detected server IP: $server_ip" + fi + # Simple VCL with comprehensive admin page bypasses cat > "$VARNISH_VCL" <<'EOFVCL' vcl 4.1; # Backend definition - Apache on port 81 (ea-nginx stock port) backend default { - .host = "127.0.0.1"; + .host = "SERVER_IP_PLACEHOLDER"; .port = "81"; .connect_timeout = 600s; .first_byte_timeout = 600s; @@ -606,6 +615,9 @@ sub vcl_deliver { } EOFVCL + # Replace placeholder with actual server IP + sed -i "s/SERVER_IP_PLACEHOLDER/$server_ip/g" "$VARNISH_VCL" + # Test VCL configuration # Note: /tmp is usually mounted with noexec on cPanel servers, so use -n parameter # to specify a working directory outside /tmp