Hello,
I am setting up a proxy that accepts only image requests and sends them to upstream (internet).
Sample config:
# Limit requests to only images
default_type image/webp;
if ($request_uri !~* ^.+\.(jpg|jpeg|gif|css|png|html|htm|ico|xml|svg) ) {
return 403;
break;
}
The problem is there will be images without extension. How do we tackle that? I did try with Lua but didn't help
for eg: https://test.com/shark.png - works (HTTP 200)
https://test.com/shark - Doesnt work (HTTP 403)
# Testing (this is just for testing If the logic works, but doesn't seem to)
header_filter_by_lua '
local val = ngx.header["testheader"]
if val then
if (val ~= "img") or (val ~= "image") then
return ngx.exit(400)
end
end
---
Can anyone provide some pointers around it?