mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-14 01:34:47 +08:00
fix: 解决反向代理网站停止不生效的问题 (#878)
This commit is contained in:
parent
c69d162f5a
commit
e672d1d896
@ -497,16 +497,32 @@ func opWebsite(website *model.Website, operate string) error {
|
|||||||
}
|
}
|
||||||
server := servers[0]
|
server := servers[0]
|
||||||
if operate == constant.StopWeb {
|
if operate == constant.StopWeb {
|
||||||
if website.Type == constant.Deployment || website.Type == constant.Static || website.Type == constant.Proxy {
|
proxyInclude := fmt.Sprintf("/www/sites/%s/proxy/*.conf", website.Alias)
|
||||||
|
server.RemoveDirective("include", []string{proxyInclude})
|
||||||
|
rewriteInclude := fmt.Sprintf("/www/sites/%s/rewrite/%s.conf", website.Alias, website.Alias)
|
||||||
|
server.RemoveDirective("include", []string{rewriteInclude})
|
||||||
|
|
||||||
|
switch website.Type {
|
||||||
|
case constant.Deployment:
|
||||||
server.RemoveDirective("location", []string{"", "/"})
|
server.RemoveDirective("location", []string{"", "/"})
|
||||||
}
|
case constant.Runtime:
|
||||||
if website.Type == constant.Runtime {
|
|
||||||
server.RemoveDirective("location", []string{"~", "[^/]\\.php(/|$)"})
|
server.RemoveDirective("location", []string{"~", "[^/]\\.php(/|$)"})
|
||||||
}
|
}
|
||||||
server.UpdateRoot("/usr/share/nginx/html/stop")
|
server.UpdateRoot("/usr/share/nginx/html/stop")
|
||||||
website.Status = constant.WebStopped
|
website.Status = constant.WebStopped
|
||||||
}
|
}
|
||||||
if operate == constant.StartWeb {
|
if operate == constant.StartWeb {
|
||||||
|
proxyInclude := fmt.Sprintf("/www/sites/%s/proxy/*.conf", website.Alias)
|
||||||
|
absoluteIncludeDir := path.Join(nginxInstall.Install.GetPath(), fmt.Sprintf("/www/sites/%s/proxy", website.Alias))
|
||||||
|
if files.NewFileOp().Stat(absoluteIncludeDir) {
|
||||||
|
server.UpdateDirective("include", []string{proxyInclude})
|
||||||
|
}
|
||||||
|
server.UpdateDirective("include", []string{proxyInclude})
|
||||||
|
rewriteInclude := fmt.Sprintf("/www/sites/%s/rewrite/%s.conf", website.Alias, website.Alias)
|
||||||
|
absoluteRewritePath := path.Join(nginxInstall.Install.GetPath(), rewriteInclude)
|
||||||
|
if files.NewFileOp().Stat(absoluteRewritePath) {
|
||||||
|
server.UpdateDirective("include", []string{rewriteInclude})
|
||||||
|
}
|
||||||
switch website.Type {
|
switch website.Type {
|
||||||
case constant.Deployment:
|
case constant.Deployment:
|
||||||
server.RemoveDirective("root", nil)
|
server.RemoveDirective("root", nil)
|
||||||
@ -521,7 +537,6 @@ func opWebsite(website *model.Website, operate string) error {
|
|||||||
server.UpdateRootLocation()
|
server.UpdateRootLocation()
|
||||||
case constant.Proxy:
|
case constant.Proxy:
|
||||||
server.RemoveDirective("root", nil)
|
server.RemoveDirective("root", nil)
|
||||||
server.UpdateRootProxy([]string{website.Proxy})
|
|
||||||
case constant.Runtime:
|
case constant.Runtime:
|
||||||
rootIndex := path.Join("/www/sites", website.Alias, "index")
|
rootIndex := path.Join("/www/sites", website.Alias, "index")
|
||||||
server.UpdateRoot(rootIndex)
|
server.UpdateRoot(rootIndex)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user