File size: 1,815 Bytes
14d56d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
events {
    worker_connections 8192;
}

http {
    log_format jirack_log '$remote_addr - $remote_user [$time_local] '
                         '"$request" $status $body_bytes_sent '
                         '"$http_referer" "$http_user_agent" '
                         'rt=$request_time';

    access_log /var/log/nginx/access.log jirack_log;
    error_log /var/log/nginx/error.log warn;

    # Rate limiting
    limit_req_zone $binary_remote_addr zone=jirack_limit:20m rate=30r/m;

    # Upstream — исправленные имена под 1B docker-compose
    upstream jirack_backend {
        least_conn;                    # Least connections — оптимально
        server jirack1:7869 max_fails=3 fail_timeout=10s;
        server jirack2:7869 max_fails=3 fail_timeout=10s;
        server jirack3:7869 max_fails=3 fail_timeout=10s;
        server jirack4:7869 max_fails=3 fail_timeout=10s;
        server jirack5:7869 max_fails=3 fail_timeout=10s;
    }

    server {
        listen 80;

        location / {
            limit_req zone=jirack_limit burst=15 nodelay;

            proxy_pass http://jirack_backend;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            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 X-Forwarded-Proto $scheme;

            proxy_buffering off;
            proxy_request_buffering off;
            proxy_read_timeout 600s;
            proxy_send_timeout 600s;

            chunked_transfer_encoding on;
            proxy_hide_header X-Powered-By;
        }

        # Healthcheck
        location /health {
            access_log off;
            return 200 "healthy\n";
        }
    }
}