2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 07:57:21 +08:00

feat: 优化禁用网站

This commit is contained in:
2026-01-17 00:59:15 +08:00
parent 53571eaf92
commit 0d04c872aa
2 changed files with 7 additions and 10 deletions

View File

@@ -121,11 +121,10 @@ func (v *baseVhost) SetEnable(enable bool) error {
return fmt.Errorf("failed to remove disable config: %w", err)
}
} else {
// 禁用:写入重定向规则,所有请求返回禁用页面
// 禁用:所有请求重写到禁用页面
content := fmt.Sprintf(`# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!
RewriteEngine On
RewriteRule ^ - [R=503,L]
ErrorDocument 503 %s
RewriteRule ^ %s [L]
`, DisablePage)
if err := os.WriteFile(disableConf, []byte(content), 0600); err != nil {
return fmt.Errorf("failed to write disable config: %w", err)

View File

@@ -117,15 +117,13 @@ func (v *baseVhost) SetEnable(enable bool) error {
return fmt.Errorf("failed to remove disable config: %w", err)
}
} else {
// 禁用:写入 return 规则,所有请求返回禁用页面
// 禁用:所有请求重写到禁用页面
content := fmt.Sprintf(`# Auto-generated by AcePanel. DO NOT EDIT MANUALLY!
error_page 503 @stop;
return 503;
location @stop {
default_type text/html;
alias %s;
rewrite ^ /stop.html last;
location = /stop.html {
root %s;
}
`, DisablePage)
`, filepath.Dir(DisablePage))
if err := os.WriteFile(disableConf, []byte(content), 0600); err != nil {
return fmt.Errorf("failed to write disable config: %w", err)
}