Skip to content

Commit

Permalink
Merge pull request #22 from Danipulok/feat/nginx-local-mode-support
Browse files Browse the repository at this point in the history
feat(nginx): support `local-mode` file paths
  • Loading branch information
JrooTJunior authored Jan 16, 2025
2 parents 13e606c + 2762361 commit cfe84d6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion example/nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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:<hidden-token>/$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;
Expand Down

0 comments on commit cfe84d6

Please sign in to comment.