每当请求包含波浪号字符 (~) 时,我想返回 403
例如:https://example.com/~/item-1/
或者甚至。https://example.com/item1?status=~pending
我希望上面返回 403
我的想法是拥有类似下面的配置,但我不确定如何完成正则表达式部分。
map $request_uri $filefromarg {
[WHAT-REGEX-HERE];
default $request_uri;
}
try_files $filefromarg $uri =403;
请分享如何执行此操作以及可能的正则表达式模式。
此配置基于帖子 How to block access to php tilde files in nginx: