简体   繁体   中英

How can I deny a request with a specific url encoded character?

I'm having problems with a site being exploited, and I have tried many ways to solve this, but I'm missing some skills to get it done.

The issue is I need to deny POST requests to "/%21/Form/create" while accepting POST requests to "/./Form/create".

I have tried:

location = /%21/Form/create {
deny all;
}
location ~ ^/%21.*/ {
deny all;
}

without any luck. I would really appreciate some help solving this.

They are the same URL - but if your server is receiving both forms of request - and you need to differentiate between them - you can use $request_uri to view the request as it was originally received.

The variable can be tested using an if block.

if ($request_uri = /%21/Form/create) { return 403; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM