(website *model.Website)
| 174 | } |
| 175 | |
| 176 | func createProxyFile(website *model.Website) error { |
| 177 | proxyFolder := GetSitePath(*website, SiteProxyDir) |
| 178 | filePath := path.Join(proxyFolder, "root.conf") |
| 179 | fileOp := files.NewFileOp() |
| 180 | if !fileOp.Stat(proxyFolder) { |
| 181 | if err := fileOp.CreateDir(proxyFolder, constant.DirPerm); err != nil { |
| 182 | return err |
| 183 | } |
| 184 | } |
| 185 | if !fileOp.Stat(filePath) { |
| 186 | if err := fileOp.CreateFile(filePath); err != nil { |
| 187 | return err |
| 188 | } |
| 189 | } |
| 190 | config, err := parser.NewStringParser(string(nginx_conf.Proxy)).Parse() |
| 191 | if err != nil { |
| 192 | return err |
| 193 | } |
| 194 | config.FilePath = filePath |
| 195 | directives := config.Directives |
| 196 | location, ok := directives[0].(*components.Location) |
| 197 | if !ok { |
| 198 | return errors.New("error") |
| 199 | } |
| 200 | location.ChangePath("^~", "/") |
| 201 | applyLocationProxyPass(location, website.Proxy, nil, "") |
| 202 | location.UpdateDirective("proxy_set_header", []string{"Host", "$host"}) |
| 203 | if err := nginx.WriteConfig(config, nginx.IndentedStyle); err != nil { |
| 204 | return buserr.WithErr("ErrUpdateBuWebsite", err) |
| 205 | } |
| 206 | return nil |
| 207 | } |
| 208 | |
| 209 | func createWebsiteFolder(website *model.Website, runtime *model.Runtime) error { |
| 210 | siteFolder := GetSiteDir(website.Alias) |
no test coverage detected