1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 22:18:07 +08:00

feat: 网站 access_log 使用主配置文件参数 (#5255)

This commit is contained in:
zhengkunwang 2024-06-03 11:23:43 +08:00 committed by GitHub
parent 6011f35f59
commit caee2159a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -1044,14 +1044,16 @@ func (w WebsiteService) OpWebsiteLog(req request.WebsiteLogReq) (*response.Websi
case constant.EnableLog:
key := "access_log"
logPath := path.Join("/www", "sites", website.Alias, "log", req.LogType)
params := []string{logPath}
switch req.LogType {
case constant.AccessLog:
params = append(params, "main")
website.AccessLog = true
case constant.ErrorLog:
key = "error_log"
website.ErrorLog = true
}
if err := updateNginxConfig(constant.NginxScopeServer, []dto.NginxParam{{Name: key, Params: []string{logPath}}}, &website); err != nil {
if err := updateNginxConfig(constant.NginxScopeServer, []dto.NginxParam{{Name: key, Params: params}}, &website); err != nil {
return nil, err
}
if err := websiteRepo.Save(context.Background(), &website); err != nil {

View File

@ -235,7 +235,7 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a
server.UpdateServerName(serverNames)
siteFolder := path.Join("/www", "sites", website.Alias)
server.UpdateDirective("access_log", []string{path.Join(siteFolder, "log", "access.log")})
server.UpdateDirective("access_log", []string{path.Join(siteFolder, "log", "access.log"), "main"})
server.UpdateDirective("error_log", []string{path.Join(siteFolder, "log", "error.log")})
rootIndex := path.Join("/www/sites", website.Alias, "index")