lobe-chat icon indicating copy to clipboard operation
lobe-chat copied to clipboard

[Question] 使用cloudflare tunnel 部署时无法流式回应

Open wenwen12345 opened this issue 7 months ago • 4 comments

🧐 问题描述 | Proposed Solution

如题,无法在使用 cloudflare tunnel 部署时使用流式回应

📝 补充信息 | Additional Information

No response

wenwen12345 avatar Dec 23 '23 10:12 wenwen12345

👀 @wenwen12345

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

lobehubbot avatar Dec 23 '23 10:12 lobehubbot

看看这个是不是相关问题: https://github.com/lobehub/lobe-chat/discussions/540

arvinxx avatar Dec 28 '23 15:12 arvinxx

oneapi 没有上https 只是 把lobechat暴露了出去

wenwen12345 avatar Dec 29 '23 03:12 wenwen12345

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


oneapi does not go to https, it just exposes lobechat.

lobehubbot avatar Dec 29 '23 03:12 lobehubbot

与 #540 无关。 参考 https://github.com/cloudflare/cloudflared/issues/199#issuecomment-1660741101 需要加上 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.kubernetes.io/configuration-snippet: |
+++      if ($uri ~* "^/api/openai/chat") {
+++        more_set_headers "Content-Type: text/event-stream";
+++      }
...

Evsio0n avatar Jan 11 '24 14:01 Evsio0n