mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-08 01:20:07 +08:00
feat: 网站 access_log 使用主配置文件参数 (#5255)
This commit is contained in:
parent
6011f35f59
commit
caee2159a8
@ -1044,14 +1044,16 @@ func (w WebsiteService) OpWebsiteLog(req request.WebsiteLogReq) (*response.Websi
|
|||||||
case constant.EnableLog:
|
case constant.EnableLog:
|
||||||
key := "access_log"
|
key := "access_log"
|
||||||
logPath := path.Join("/www", "sites", website.Alias, "log", req.LogType)
|
logPath := path.Join("/www", "sites", website.Alias, "log", req.LogType)
|
||||||
|
params := []string{logPath}
|
||||||
switch req.LogType {
|
switch req.LogType {
|
||||||
case constant.AccessLog:
|
case constant.AccessLog:
|
||||||
|
params = append(params, "main")
|
||||||
website.AccessLog = true
|
website.AccessLog = true
|
||||||
case constant.ErrorLog:
|
case constant.ErrorLog:
|
||||||
key = "error_log"
|
key = "error_log"
|
||||||
website.ErrorLog = true
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := websiteRepo.Save(context.Background(), &website); err != nil {
|
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)
|
server.UpdateServerName(serverNames)
|
||||||
|
|
||||||
siteFolder := path.Join("/www", "sites", website.Alias)
|
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")})
|
server.UpdateDirective("error_log", []string{path.Join(siteFolder, "log", "error.log")})
|
||||||
|
|
||||||
rootIndex := path.Join("/www/sites", website.Alias, "index")
|
rootIndex := path.Join("/www/sites", website.Alias, "index")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user