| events { | |
| worker_connections 1024; | |
| } | |
| http { | |
| upstream monica-proxy { | |
| server monica-proxy:8080; | |
| } | |
| server { | |
| listen 80; | |
| location / { | |
| # 必须使用 HTTP/1.1,才能支持 chunked 传输 | |
| proxy_http_version 1.1; | |
| # 去掉 Connection: close,避免长连接被关闭 | |
| proxy_set_header Connection ''; | |
| # 指定后端地址 | |
| proxy_pass http://monica-proxy; | |
| # 关闭 Nginx 的各种缓存与缓冲 | |
| proxy_buffering off; | |
| proxy_cache off; | |
| # 这一行可以确保 Nginx 不再做加速层的缓冲 | |
| proxy_set_header X-Accel-Buffering off; | |
| # 打开分块传输 | |
| chunked_transfer_encoding on; | |
| proxy_read_timeout 3600s; | |
| proxy_send_timeout 3600s; | |
| } | |
| gzip on; | |
| # 不包含 text/event-stream | |
| gzip_types text/plain application/json; | |
| } | |
| } |