mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 03:07:20 +08:00
feat: 为生成的web服务器编辑添加请勿修改标识
This commit is contained in:
@@ -15,7 +15,8 @@ const (
|
||||
)
|
||||
|
||||
// DefaultVhostConf 默认配置模板
|
||||
const DefaultVhostConf = `<VirtualHost *:80>
|
||||
const DefaultVhostConf = `# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!
|
||||
<VirtualHost *:80>
|
||||
ServerName localhost
|
||||
DocumentRoot /opt/ace/sites/default/public
|
||||
DirectoryIndex index.php index.html
|
||||
|
||||
@@ -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("<IfModule mod_proxy_balancer.c>\n")
|
||||
sb.WriteString(fmt.Sprintf(" <Proxy balancer://%s>\n", upstream.Name))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 配置
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user