location = /ai/chat/stream { # 精确匹配路径(不含末尾斜杠)
# 强制转换为POST方法(OpenAI接口要求)
if ($request_method != POST) {
return 405;
}
# 关键配置:清理路径后缀
#rewrite ^ /v1/chat/completions break;
# 代理配置
proxy_pass http://1localhost:11434/v1/chat/completions;
# 设置代理头信息
proxy_set_header Authorization "Bearer 123"; # 在此处固定Token
proxy_http_version 1.1; # 保持HTTP长连接
proxy_pass_request_body on; # 透传请求体
proxy_pass_request_headers on; # 透传请求头
# 优化代理性能
proxy_buffering off; # 关闭缓冲以支持流式响应
proxy_read_timeout 1800s; # 设置长超时时间
}
使用nginx转发openai/deepseek的流式请求
发布于 16 天前 运维 最后更新于 16 天前
Comments NOTHING