mirror of https://github.com/1Panel-dev/1Panel
feat: 网站 access_log 使用主配置文件参数 (#5255)
parent
6011f35f59
commit
caee2159a8
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue