简体   繁体   English

如何拒绝具有特定 url 编码字符的请求?

[英]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".问题是我需要拒绝对“/%21/Form/create”的 POST 请求,同时接受对“/./Form/create”的 POST 请求。

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.它们是相同的 URL - 但如果您的服务器正在接收两种形式的请求 - 并且您需要区分它们 - 您可以使用$request_uri来查看最初收到的请求。

The variable can be tested using an if block.可以使用if块测试该变量。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Nginx中,如何在不向应用服务器发送请求的情况下为特定的URL模式/正则表达式返回404? - In Nginx, how can I return 404s for specific URL pattern/regex without sending request to the app server? 如何在nginx中拒绝POST到某些URL - How to deny POST to certain url in nginx nginx重写URL解码URI中的第一个编码字符 - nginx rewrite URL decoding first encoded character in URI 如何使用 Nginx 重定向编码的 url slug - How to redirect an encoded url slug with Nginx Nginx:如何将代理从外部请求反向到特定的 localhost url - Nginx: How to reverse proxy from external request to specific localhost url 如何根据Nginx中的请求URL重定向到特定的上游服务器? - How to redirect to specific upstream servers based on request URL in Nginx? 如何配置Nginx将特定请求模式路由到托管Symfony应用程序的特定php-fpm上游? - How can I configure Nginx to route a specific request pattern to a specific php-fpm upstream hosting a Symfony application? Nginx拒绝位置中的特定文件类型 - Nginx deny specific filetypes in a location 在 AWS 中,我需要帮助以通过公共 ip 或公共 dns 拒绝 url 并仅允许通过域(CNAME)访问 - In AWS I need help for deny url by public ip or public dns and to allow only access by domain (CNAME) 如何在nginx上拒绝使用404 - How to deny with 404 on nginx
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM