# use $sanitized_request instead of $request to hide Telegram token log_format token_filter '$remote_addr - $remote_user [$time_local] ' '"$sanitized_request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent"'; 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; set $sanitized_request $request; if ( $sanitized_request ~ (\w+)\s(\/bot\d+):[-\w]+\/(\S+)\s(.*) ) { set $sanitized_request "$1 $2:/$3 $4"; } access_log /var/log/nginx/access.log token_filter; 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; } }