Skip to content

Commit 45373f9

Browse files
feat: 网站 access_log 使用主配置文件参数 (1Panel-dev#5255)
1 parent 7b42a03 commit 45373f9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

backend/app/service/website.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,14 +1044,16 @@ func (w WebsiteService) OpWebsiteLog(req request.WebsiteLogReq) (*response.Websi
10441044
case constant.EnableLog:
10451045
key := "access_log"
10461046
logPath := path.Join("/www", "sites", website.Alias, "log", req.LogType)
1047+
params := []string{logPath}
10471048
switch req.LogType {
10481049
case constant.AccessLog:
1050+
params = append(params, "main")
10491051
website.AccessLog = true
10501052
case constant.ErrorLog:
10511053
key = "error_log"
10521054
website.ErrorLog = true
10531055
}
1054-
if err := updateNginxConfig(constant.NginxScopeServer, []dto.NginxParam{{Name: key, Params: []string{logPath}}}, &website); err != nil {
1056+
if err := updateNginxConfig(constant.NginxScopeServer, []dto.NginxParam{{Name: key, Params: params}}, &website); err != nil {
10551057
return nil, err
10561058
}
10571059
if err := websiteRepo.Save(context.Background(), &website); err != nil {

backend/app/service/website_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a
235235
server.UpdateServerName(serverNames)
236236

237237
siteFolder := path.Join("/www", "sites", website.Alias)
238-
server.UpdateDirective("access_log", []string{path.Join(siteFolder, "log", "access.log")})
238+
server.UpdateDirective("access_log", []string{path.Join(siteFolder, "log", "access.log"), "main"})
239239
server.UpdateDirective("error_log", []string{path.Join(siteFolder, "log", "error.log")})
240240

241241
rootIndex := path.Join("/www/sites", website.Alias, "index")

0 commit comments

Comments
 (0)