I recently try to use http_substitution_filter_module
to filter and replace some content in my nginx server.
After I added the subs_filter
rule, I can no longer use Range
header to retrieve the part of file but the full content.
Example:
flag.txt
in /var/www/html
with content:
The flag is FLAG{IAMFLAGYEEAH}.
I can use curl -r 13-16 <server-address>/flag.txt
to get only part of file. Output:
LAG{
But if I enabled sub_filter
rule, Range
header no longer works.
By using same command, I get the following result:
The flag is FLAG{NOFLAGFORYOU}.
Although filter works perfectly, the full content is returned.
Here is my nginx/sites-enabled/default
config (other settings is same as the default one):
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
subs_filter_types text/plain;
subs_filter "FLAG{\w*}" "FLAG{NOFLAGFORYOU}" ir;
}
and my nginx version is 1.14.0
.
The module was installed by command apt install libnginx-mod-http-subs-filter
.
How should I keep Range
header working and also filter the content at the same time?