admin管理员组文章数量:1032896
Nginx反向代理大模型推理接口(SSE)
Nginx作用这么大?
在后台写了一个接口,用来调用第三方的AI接口,SSE方式返回。
用普通的Nginx代理配置接口返回特别慢。
找了下原因,发现是代理配置有问题。
Nginx反向代理配置
代码语言:javascript代码运行次数:0运行复制location /ai-interface {
add_header X-XSS-Protection "1;mode=block";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Scheme $scheme;
proxy_set_header Accept-Encoding "";
proxy_ssl_session_reuse on;
proxy_redirect off;
proxy_ignore_client_abort on;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_connect_timeout 86400s;
# SSE 连接时的超时时间
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
proxy_pass http://192.168.0.105:228866;
}
配置之后,重启一下Nginx。
接口总算丝滑了。
代码语言:javascript代码运行次数:0运行复制http://192.168.0.105:228866
这个地址是你对应第三方AI大模型返回数据的接口。
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。原始发表:2025-04-02,如有侵权请联系 cloudcommunity@tencent 删除接口模型nginxsse反向代理Nginx反向代理大模型推理接口(SSE)
Nginx作用这么大?
在后台写了一个接口,用来调用第三方的AI接口,SSE方式返回。
用普通的Nginx代理配置接口返回特别慢。
找了下原因,发现是代理配置有问题。
Nginx反向代理配置
代码语言:javascript代码运行次数:0运行复制location /ai-interface {
add_header X-XSS-Protection "1;mode=block";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Scheme $scheme;
proxy_set_header Accept-Encoding "";
proxy_ssl_session_reuse on;
proxy_redirect off;
proxy_ignore_client_abort on;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_connect_timeout 86400s;
# SSE 连接时的超时时间
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
proxy_pass http://192.168.0.105:228866;
}
配置之后,重启一下Nginx。
接口总算丝滑了。
代码语言:javascript代码运行次数:0运行复制http://192.168.0.105:228866
这个地址是你对应第三方AI大模型返回数据的接口。
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。原始发表:2025-04-02,如有侵权请联系 cloudcommunity@tencent 删除接口模型nginxsse反向代理本文标签: Nginx反向代理大模型推理接口(SSE)
版权声明:本文标题:Nginx反向代理大模型推理接口(SSE) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/jiaocheng/1747979669a2236830.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论