1

I'm trying to get file downloading in the local Telegram Bot API work. I found an example on github how to do it with nginx: https://github.com/aiogram/telegram-bot-api/tree/master/example. It's working perfectly with relative paths (e.g documents/file_0.txt). But I need to request file via full path (e.g. /var/lib/telegram-bot-api/bot-token/documents/file_0.txt). When I try to do it, nginx is looking for /var/lib/telegram-bot-api/full path and throws 404. What do I need to change here to fix it? I'm a complete noob in nginx. Here's the config:

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:<hidden-token>/$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; } }``` 
1
  • I'm facing the same! But that works: curl -i http://nginx:81/file/botTOKEN_ID:TOKEN_HASH/documents/file_16.apk Did you @NitroRX resolve it ? Commented Apr 4, 2023 at 14:34

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.