[Q&A] 使用cloudflare tunnel 部署时无法流式回应 #1016
-
🧐 问题描述 | Proposed Solution如题,无法在使用 cloudflare tunnel 部署时使用流式回应 📝 补充信息 | Additional InformationNo response |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 5 replies
-
Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. |
Beta Was this translation helpful? Give feedback.
-
看看这个是不是相关问题: #540 |
Beta Was this translation helpful? Give feedback.
-
oneapi 没有上https 只是 把lobechat暴露了出去 |
Beta Was this translation helpful? Give feedback.
-
oneapi does not go to https, it just exposes lobechat. |
Beta Was this translation helpful? Give feedback.
-
与 #540 无关。 改写nginx反代: location /api/openai/chat {
proxy_pass http://your_backend_service;
# 添加或更改响应头
+++ add_header Content-Type text/event-stream;
# 你通常需要关闭缓冲
proxy_buffering off;
#其他配置,如websocketset header 等等,
......
} kubernetes nginx-ingress示例 kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
name: lobe-chat-ingress-lsoz4j
namespace: lobe-chat
labels:
app.kubernetes.io/name: lobe-chat
app.kubernetes.io/version: v1
annotations:
nginx.ingress.kubernetes.io/proxy-buffering: 'off'
+++ nginx.ingress.kubernetes.io/configuration-snippet: |
+++ if ($uri ~* "^/api/openai/chat") {
+++ more_set_headers "Content-Type: text/event-stream";
+++ }
... |
Beta Was this translation helpful? Give feedback.
-
add_header Content-Type text/event-stream; |
Beta Was this translation helpful? Give feedback.
-
按照这位兄弟 @xorrvin 的配置成功了 |
Beta Was this translation helpful? Give feedback.
-
大佬们,如何使用CF部署lobe啊 |
Beta Was this translation helpful? Give feedback.
与 #540 无关。
参考 cloudflare/cloudflared#199 (comment)
需要加上
text/event-stream
header cloudflare才会no proxy buffer改写nginx反代:
location /api/openai/chat { proxy_pass http://your_backend_service; # 添加或更改响应头 +++ add_header Content-Type text/event-stream; # 你通常需要关闭缓冲 proxy_buffering off; #其他配置,如websocketset header 等等, ...... }
kubernetes nginx-ingress示例
kind: Ingress apiVersion: networking.k8s.io/v1 metadata: name: lobe-chat-ingress-lsoz4j namespace: lobe-chat labels: app.kubernetes.io/name: lobe-chat app.kubernetes.io/version: v1 annotations: nginx.ingress.kubernetes.io/proxy-buffering: 'off' +++ nginx.ingress…