diff --git a/pkg/webserver/apache/data.go b/pkg/webserver/apache/data.go index b74346a2..e7a9ca75 100644 --- a/pkg/webserver/apache/data.go +++ b/pkg/webserver/apache/data.go @@ -15,7 +15,8 @@ const ( ) // DefaultVhostConf 默认配置模板 -const DefaultVhostConf = ` +const DefaultVhostConf = `# Auto-generated by AcePanel. DO NOT EDIT MANUALLY! + ServerName localhost DocumentRoot /opt/ace/sites/default/public DirectoryIndex index.php index.html diff --git a/pkg/webserver/apache/proxy.go b/pkg/webserver/apache/proxy.go index e4731174..2a624c96 100644 --- a/pkg/webserver/apache/proxy.go +++ b/pkg/webserver/apache/proxy.go @@ -199,6 +199,7 @@ func generateProxyConfig(proxy types.Proxy) string { proxy.Pass += "/" } + sb.WriteString("# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!\n") sb.WriteString(fmt.Sprintf("# Reverse proxy: %s -> %s\n", location, proxy.Pass)) // 启用代理模块 @@ -395,6 +396,7 @@ func clearBalancerFiles(sharedDir string) error { func generateBalancerConfig(upstream types.Upstream) string { var sb strings.Builder + sb.WriteString("# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!\n") sb.WriteString(fmt.Sprintf("# Load balancer: %s\n", upstream.Name)) sb.WriteString("\n") sb.WriteString(fmt.Sprintf(" \n", upstream.Name)) diff --git a/pkg/webserver/apache/redirect.go b/pkg/webserver/apache/redirect.go index 7d556c29..06693342 100644 --- a/pkg/webserver/apache/redirect.go +++ b/pkg/webserver/apache/redirect.go @@ -187,6 +187,7 @@ func generateRedirectConfig(redirect types.Redirect) string { switch redirect.Type { case types.RedirectTypeURL: // URL 重定向 + sb.WriteString("# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!\n") sb.WriteString(fmt.Sprintf("# URL redirect: %s -> %s\n", redirect.From, redirect.To)) if redirect.KeepURI { // 使用 RedirectMatch 保持 URI diff --git a/pkg/webserver/nginx/data.go b/pkg/webserver/nginx/data.go index 104fb549..e9c12c8a 100644 --- a/pkg/webserver/nginx/data.go +++ b/pkg/webserver/nginx/data.go @@ -15,7 +15,8 @@ const ( UpstreamStartNum = 100 // 上游服务器配置起始序号 ) -const DefaultConf = `include /opt/ace/sites/default/config/shared/*.conf; +const DefaultConf = `# Auto-generated by AcePanel. DO NOT EDIT MANUALLY! +include /opt/ace/sites/default/config/shared/*.conf; server { listen 80; server_name localhost; diff --git a/pkg/webserver/nginx/proxy.go b/pkg/webserver/nginx/proxy.go index 13641861..2920b370 100644 --- a/pkg/webserver/nginx/proxy.go +++ b/pkg/webserver/nginx/proxy.go @@ -213,6 +213,8 @@ func generateProxyConfig(proxy types.Proxy) string { location := proxy.Location + sb.WriteString("# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!\n") + sb.WriteString(fmt.Sprintf("# Reverse proxy: %s -> %s\n", location, proxy.Pass)) sb.WriteString(fmt.Sprintf("location %s {\n", location)) // resolver 配置 @@ -224,6 +226,7 @@ func generateProxyConfig(proxy types.Proxy) string { } sb.WriteString(fmt.Sprintf(" proxy_pass %s;\n", proxy.Pass)) + sb.WriteString(fmt.Sprintf(" proxy_http_version 2;\n")) // Host 头 if proxy.Host != "" { @@ -236,13 +239,20 @@ func generateProxyConfig(proxy types.Proxy) string { sb.WriteString(" proxy_set_header X-Real-IP $remote_addr;\n") sb.WriteString(" proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n") sb.WriteString(" proxy_set_header X-Forwarded-Proto $scheme;\n") + sb.WriteString(" proxy_set_header Upgrade $http_upgrade;\n") + sb.WriteString(" proxy_set_header Connection $connection_upgrade;\n") + sb.WriteString(" proxy_set_header Early-Data $ssl_early_data;\n") // SNI 配置 if strings.HasPrefix(proxy.Pass, "https") { + sb.WriteString(" proxy_ssl_protocols TLSv1.2 TLSv1.3;\n") + sb.WriteString(" proxy_ssl_session_reuse off;\n") sb.WriteString(" proxy_ssl_server_name on;\n") - } - if proxy.SNI != "" { - sb.WriteString(fmt.Sprintf(" proxy_ssl_name %s;\n", proxy.SNI)) + if proxy.SNI != "" { + sb.WriteString(fmt.Sprintf(" proxy_ssl_name %s;\n", proxy.SNI)) + } else { + sb.WriteString(" proxy_ssl_name $proxy_host;\n") + } } // Buffering 配置 diff --git a/pkg/webserver/nginx/redirect.go b/pkg/webserver/nginx/redirect.go index f437f245..cf3b44b5 100644 --- a/pkg/webserver/nginx/redirect.go +++ b/pkg/webserver/nginx/redirect.go @@ -174,6 +174,7 @@ func generateRedirectConfig(redirect types.Redirect) string { switch redirect.Type { case types.RedirectTypeURL: // URL 重定向 + sb.WriteString("# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!\n") sb.WriteString(fmt.Sprintf("# URL redirect: %s -> %s\n", redirect.From, redirect.To)) sb.WriteString(fmt.Sprintf("location = %s {\n", redirect.From)) if redirect.KeepURI { diff --git a/pkg/webserver/nginx/upstream.go b/pkg/webserver/nginx/upstream.go index f8f35d2d..595e8d9d 100644 --- a/pkg/webserver/nginx/upstream.go +++ b/pkg/webserver/nginx/upstream.go @@ -198,6 +198,7 @@ func clearUpstreamFiles(sharedDir string) error { func generateUpstreamConfig(upstream types.Upstream) string { var sb strings.Builder + sb.WriteString("# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!\n") sb.WriteString(fmt.Sprintf("# Upstream: %s\n", upstream.Name)) sb.WriteString(fmt.Sprintf("upstream %s {\n", upstream.Name))