upstream telegram-bot-api { server api:8081; } server { listen 80; server_name _; chunked_transfer_encoding on; proxy_connect_timeout 600; proxy_send_timeout 600; proxy_read_timeout 600; send_timeout 600; client_max_body_size 2G; client_body_buffer_size 30M; keepalive_timeout 0; location ~* \/file\/bot\d+:(.*) { rewrite ^/file\/bot(.*) /$1 break; try_files $uri @files; } location / { try_files $uri @api; } location @files { root /var/lib/telegram-bot-api; gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 64 8k; gzip_http_version 1.1; gzip_min_length 1100; } location @api { proxy_pass http://telegram-bot-api; proxy_redirect off; 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-Host $server_name; } }