Skip to content

[Q&A] 使用cloudflare tunnel 部署时无法流式回应 #1016

Discussion options

You must be logged in to vote

#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…

Replies: 8 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@Evsio0n
Comment options

@arvinxx
Comment options

@Evsio0n
Comment options

Answer selected by arvinxx
Comment options

You must be logged in to vote
2 replies
@Evsio0n
Comment options

@xqxrrz1ge2
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😇 Help Wanted Need help | 需要帮助
6 participants
Converted from issue

This discussion was converted from issue #781 on January 11, 2024 14:25.