From 276236114f936d96b4aff2bb91faa80268962b94 Mon Sep 17 00:00:00 2001 From: Danipulok Date: Mon, 6 Jan 2025 09:39:07 +0200 Subject: [PATCH] feat(nginx): support `local-mode` file paths --- example/nginx/default.conf | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/example/nginx/default.conf b/example/nginx/default.conf index 0ebe396..9425d60 100644 --- a/example/nginx/default.conf +++ b/example/nginx/default.conf @@ -19,13 +19,20 @@ server { 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; + # Handle full paths (e.g., "/var/lib/telegram-bot-api/TOKEN/videos/file_0.mp4") + location ~* ^/file\/bot[^/]+\/var\/lib\/telegram-bot-api(.*) { + rewrite ^/file\/bot[^/]+\/var\/lib\/telegram-bot-api(.*) /$1 break; + try_files $uri @files; + } + + # Handle partial paths (e.g., "videos/file_0.mp4") location ~* \/file\/bot\d+:(.*) { rewrite ^/file\/bot(.*) /$1 break; try_files $uri @files;