diff --git a/backend/app/service/website.go b/backend/app/service/website.go index d54a35555f53..cc458273f11f 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -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 { diff --git a/backend/app/service/website_utils.go b/backend/app/service/website_utils.go index 5c9ebab0d49b..0bf55887e270 100644 --- a/backend/app/service/website_utils.go +++ b/backend/app/service/website_utils.go @@ -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")