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

fix: lint

This commit is contained in:
2025-04-12 19:09:55 +08:00
parent d36c3b0dae
commit 90140f4229
3 changed files with 40 additions and 32 deletions

View File

@@ -224,7 +224,11 @@ func (r *websiteRepo) List(page, limit uint) ([]*biz.Website, int64, error) {
func (r *websiteRepo) Create(req *request.WebsiteCreate) (*biz.Website, error) {
// 初始化nginx配置
p, err := nginx.NewParser()
config := nginx.DefaultConf
if app.Locale == "zh_CN" {
config = nginx.DefaultConfZh
}
p, err := nginx.NewParser(config)
if err != nil {
return nil, err
}
@@ -609,7 +613,11 @@ func (r *websiteRepo) ResetConfig(id uint) error {
}
// 初始化nginx配置
p, err := nginx.NewParser()
config := nginx.DefaultConf
if app.Locale == "zh_CN" {
config = nginx.DefaultConfZh
}
p, err := nginx.NewParser(config)
if err != nil {
return err
}

View File

@@ -4,35 +4,7 @@ var order = []string{"listen", "server_name", "index", "root",
"ssl_certificate", "ssl_certificate_key", "ssl_session_timeout", "ssl_session_cache", "ssl_protocols", "ssl_ciphers", "ssl_prefer_server_ciphers", "ssl_early_data", "ssl_stapling", "ssl_stapling_verify", "ssl_trusted_certificate",
"resolver", "error_page", "include", "if", "location", "add_header", "access_log", "error_log"}
const defaultConf = `server {
listen 80;
server_name localhost;
index index.php index.html index.htm;
root /www/wwwroot/default;
# 错误页配置
error_page 404 /404.html;
include enable-php-0.conf;
# 不记录静态文件日志
location ~ .*\.(bmp|jpg|jpeg|png|gif|svg|ico|tiff|webp|avif|heif|heic|jxl)$ {
expires 30d;
access_log /dev/null;
error_log /dev/null;
}
location ~ .*\.(js|css|ttf|otf|woff|woff2|eot)$ {
expires 6h;
access_log /dev/null;
error_log /dev/null;
}
# 禁止部分敏感目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.env) {
return 404;
}
access_log /www/wwwlogs/default.log;
error_log /www/wwwlogs/default.log;
}
`
const defaultConfEn = `server {
const DefaultConf = `server {
listen 80;
server_name localhost;
index index.php index.html index.htm;
@@ -59,3 +31,31 @@ const defaultConfEn = `server {
error_log /www/wwwlogs/default.log;
}
`
const DefaultConfZh = `server {
listen 80;
server_name localhost;
index index.php index.html index.htm;
root /www/wwwroot/default;
# 错误页配置
error_page 404 /404.html;
include enable-php-0.conf;
# 不记录静态文件日志
location ~ .*\.(bmp|jpg|jpeg|png|gif|svg|ico|tiff|webp|avif|heif|heic|jxl)$ {
expires 30d;
access_log /dev/null;
error_log /dev/null;
}
location ~ .*\.(js|css|ttf|otf|woff|woff2|eot)$ {
expires 6h;
access_log /dev/null;
error_log /dev/null;
}
# 禁止部分敏感目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.env) {
return 404;
}
access_log /www/wwwlogs/default.log;
error_log /www/wwwlogs/default.log;
}
`

View File

@@ -18,7 +18,7 @@ type Parser struct {
func NewParser(str ...string) (*Parser, error) {
if len(str) == 0 {
str = append(str, defaultConf)
str = append(str, DefaultConf)
}
p := parser.NewStringParser(str[0], parser.WithSkipIncludeParsingErr(), parser.WithSkipValidDirectivesErr())
c, err := p.Parse()