File size: 972 Bytes
893fb77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
    }
}