babaohuang / GeminiProChat

Minimal web UI for GeminiPro.
https://geminiprochat.com
MIT License
4.2k stars 12.33k forks source link

本地nginx代理后没有流式输出效果 #128

Open TheLastManT1 opened 6 months ago

TheLastManT1 commented 6 months ago

What operating system are you using?

openwrt

What browser are you using?

chrome

Describe the bug

本地nginx代理后没有流式输出效果。正常情况下一个长回答会逐渐输出,但是代理后就没有这个效果了,变成了等待AI回答完再一下输出全部内容 代理配置 server {#gemini listen 9105 ssl; listen [::]:9105 ssl; server_name xxxx;

ssl_certificate /etc/nginx/conf.d/_lan.crt;
ssl_certificate_key /etc/nginx/conf.d/_lan.key;
# 指定密码为openssl支持的格式
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on;  #依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密码
location / {
    proxy_pass http://192.168.1.1:9004/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Via "nginx";
}

}

What prompt did you enter?

Console Logs

Participation

tjsky commented 6 months ago

在反代配置里设定proxy_buffering off; 禁用 Nginx 的请求缓冲功能。

以你的配置为例

server {#gemini
listen 9105 ssl;
listen [::]:9105 ssl;
server_name xxxx;

ssl_certificate /etc/nginx/conf.d/_lan.crt;
ssl_certificate_key /etc/nginx/conf.d/_lan.key;
# 指定密码为openssl支持的格式
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on;  #依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密码
location / {
    proxy_pass http://192.168.1.1:9004/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Via "nginx";
    proxy_buffering off;  #禁用 Nginx 的请求缓冲功能
}
}