feat: Added streaming transmission configuration (#7875)
Some checks failed
SonarCloud Scan / SonarCloud (push) Failing after 12m4s

This commit is contained in:
zhengkunwang 2025-02-15 20:59:38 +08:00 committed by GitHub
parent 367a74503f
commit f6ee3dc75b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 12 deletions

View file

@ -233,6 +233,9 @@ func (u *AIToolService) BindDomain(req dto.OllamaBindDomain) error {
return err
}
}
if err = ConfigAIProxy(website); err != nil {
return err
}
return nil
}

View file

@ -1150,17 +1150,17 @@ func GetAllowIps(website model.Website) []string {
}
func ConfigAIProxy(website model.Website) error {
// nginxFull, err := getNginxFull(&website)
// if err != nil {
// return nil
// }
// config := nginxFull.SiteConfig.Config
// server := config.FindServers()[0]
// dirs := server.GetDirectives()
// for _, dir := range dirs {
// if dir.GetName() == "location" && dir.GetParameters()[0] == "/" {
// // server.UpdateRootProxy()
// }
// }
nginxFull, err := getNginxFull(&website)
if err != nil {
return nil
}
config := nginxFull.SiteConfig.Config
server := config.FindServers()[0]
dirs := server.GetDirectives()
for _, dir := range dirs {
if dir.GetName() == "location" && dir.GetParameters()[0] == "/" {
server.UpdateRootProxyForAi([]string{fmt.Sprintf("http://%s", website.Proxy)})
}
}
return nil
}

View file

@ -291,6 +291,18 @@ func (s *Server) UpdateRootProxyForAi(proxy []string) {
"1.1",
},
},
&Directive{
Name: "proxy_set_header",
Parameters: []string{
"Connection", "''",
},
},
&Directive{
Name: "chunked_transfer_encoding",
Parameters: []string{
"off",
},
},
}
block.Directives = append(block.Directives, &Directive{
Name: "proxy_pass",