diff --git a/internal/data/website.go b/internal/data/website.go index 184a00ab..038c3890 100644 --- a/internal/data/website.go +++ b/internal/data/website.go @@ -372,7 +372,7 @@ func (r *websiteRepo) Create(ctx context.Context, req *request.WebsiteCreate) (* if err = phpVhost.SetIndex([]string{"index.php", "index.html"}); err != nil { return nil, err } - if err = phpVhost.SetConfig("010-rewrite.conf", "site", ""); err != nil { + if err = phpVhost.SetConfig("010-rewrite.conf", "site", "", true); err != nil { return nil, err } var cacheConfig string @@ -671,7 +671,7 @@ func (r *websiteRepo) Update(ctx context.Context, req *request.WebsiteUpdate) er return err } // 伪静态 - if err = phpVhost.SetConfig("010-rewrite.conf", "site", req.Rewrite); err != nil { + if err = phpVhost.SetConfig("010-rewrite.conf", "site", req.Rewrite, true); err != nil { return err } // 防跨站 diff --git a/internal/service/cli.go b/internal/service/cli.go index 053831b5..457f42d2 100644 --- a/internal/service/cli.go +++ b/internal/service/cli.go @@ -1045,7 +1045,7 @@ func (s *CliService) Init(ctx context.Context, cmd *cli.Command) error { {Key: biz.SettingKeyProjectPath, Value: filepath.Join(app.Root, "projects")}, {Key: biz.SettingKeyContainerSock, Value: "/var/run/docker.sock"}, {Key: biz.SettingKeyWebsiteTLSVersions, Value: `["TLSv1.2","TLSv1.3"]`}, - {Key: biz.SettingKeyWebsiteCipherSuites, Value: `ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305`}, + {Key: biz.SettingKeyWebsiteCipherSuites, Value: `ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305`}, {Key: biz.SettingKeyOfflineMode, Value: "false"}, {Key: biz.SettingKeyAutoUpdate, Value: "true"}, {Key: biz.SettingHiddenMenu, Value: "[]"}, diff --git a/pkg/webserver/apache/vhost.go b/pkg/webserver/apache/vhost.go index 5ea7cf1d..2df71695 100644 --- a/pkg/webserver/apache/vhost.go +++ b/pkg/webserver/apache/vhost.go @@ -356,8 +356,11 @@ func (v *baseVhost) Config(name string, typ string) string { return strings.TrimSpace(string(content)) } -func (v *baseVhost) SetConfig(name string, typ string, content string) error { +func (v *baseVhost) SetConfig(name string, typ string, content string, skipComment ...bool) error { conf := filepath.Join(v.configDir, typ, name) + if len(skipComment) == 0 || !skipComment[0] { + content = "# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!\n" + content + } if err := os.WriteFile(conf, []byte(content), 0600); err != nil { return fmt.Errorf("failed to write config file: %w", err) } @@ -695,8 +698,7 @@ func (v *PHPVhost) SetPHP(version uint) error { // 生成 PHP-FPM 配置 // sock 路径格式: unix:/tmp/php-cgi-84.sock - content := fmt.Sprintf(`# Auto-generated by AcePanel. DO NOT EDIT MANUALLY! - + content := fmt.Sprintf(` SetHandler "proxy:unix:/tmp/php-cgi-%d.sock|fcgi://localhost/" `, version) diff --git a/pkg/webserver/nginx/vhost.go b/pkg/webserver/nginx/vhost.go index edeb91d9..42471e53 100644 --- a/pkg/webserver/nginx/vhost.go +++ b/pkg/webserver/nginx/vhost.go @@ -389,8 +389,11 @@ func (v *baseVhost) Config(name string, typ string) string { return strings.TrimSpace(string(content)) } -func (v *baseVhost) SetConfig(name string, typ string, content string) error { +func (v *baseVhost) SetConfig(name string, typ string, content string, skipComment ...bool) error { conf := filepath.Join(v.configDir, typ, name) + if len(skipComment) == 0 || !skipComment[0] { + content = "# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!\n" + content + } if err := os.WriteFile(conf, []byte(content), 0600); err != nil { return fmt.Errorf("failed to write config file: %w", err) } @@ -476,7 +479,7 @@ func (v *baseVhost) SetSSLConfig(cfg *types.SSLConfig) error { cfg.Protocols = []string{"TLSv1.2", "TLSv1.3"} } if cfg.Ciphers == "" { - cfg.Ciphers = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305" + cfg.Ciphers = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305" } err := v.parser.Set("server", []*config.Directive{ @@ -842,8 +845,7 @@ func (v *PHPVhost) SetPHP(version uint) error { // 生成 PHP-FPM 配置 // sock 路径格式: unix:/tmp/php-cgi-84.sock - content := fmt.Sprintf(`# Auto-generated by AcePanel. DO NOT EDIT MANUALLY! -location ~ \.php$ { + content := fmt.Sprintf(`location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi-%d.sock; fastcgi_index index.php; diff --git a/pkg/webserver/types/vhost.go b/pkg/webserver/types/vhost.go index d01046aa..7c5329d1 100644 --- a/pkg/webserver/types/vhost.go +++ b/pkg/webserver/types/vhost.go @@ -88,7 +88,7 @@ type Vhost interface { Config(name string, typ string) string // SetConfig 设置指定名称的配置内容 // type 可选值: "site", "shared" - SetConfig(name string, typ string, content string) error + SetConfig(name string, typ string, content string, skipComment ...bool) error // RemoveConfig 清除指定名称的配置内容 // type 可选值: "site", "shared" RemoveConfig(name string, typ string) error diff --git a/web/src/views/website/SettingView.vue b/web/src/views/website/SettingView.vue index d80885d7..0fb7caae 100644 --- a/web/src/views/website/SettingView.vue +++ b/web/src/views/website/SettingView.vue @@ -45,11 +45,11 @@ watch( if (!newVal.includes('TLSv1.1') && !newVal.includes('TLSv1.0')) { // 不包含 TLSv1.0 和 TLSv1.1 model.value.cipher_suites = - 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305' + 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305' } else { // 包含 TLSv1.0 或 TLSv1.1 model.value.cipher_suites = - '@SECLEVEL=0:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA' + '@SECLEVEL=0:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA' } } )