【问题标题】:Deny POST Requests Except to Specified URLs in NGINX拒绝 NGINX 中指定 URL 以外的 POST 请求
【发布时间】:2017-12-17 02:26:46
【问题描述】:

我们想要一些关于拒绝除 NGINX 上指定 URL 之外的所有 POST 请求的建议和代码示例。当然,如果可能的话,我们需要避免“如果是邪恶的”。

我们希望阻止整个虚拟主机的 POST 请求,但指定的 URL 除外。

我们在此处查看了类似的问题,但没有准确回答问题。

提前感谢您的帮助。

【问题讨论】:

  • 这似乎是您问题的准确答案。 serverfault.com/questions/637908/…
  • 是的,它部分回答了有关限制 POST 请求的问题,但没有提及允许 POST 请求的白名单 URL。

标签: post nginx http-post nginx-location nginx-reverse-proxy


【解决方案1】:

在配置中使用精确的确定

location = /publish/domain.io.php {
  allow all;
}

http://nginx.org/en/docs/http/ngx_http_core_module.html#location

结合两个例子。

location = /publish/domain.io.php {
  allow all;
}
location ^~ /publish{
  limit_except GET {
    deny  all;
  }
}

【讨论】:

    猜你喜欢
    • 2018-11-30
    • 2019-01-18
    • 2021-09-08
    • 2017-01-14
    • 2015-11-06
    • 1970-01-01
    • 1970-01-01
    • 2018-09-19
    • 1970-01-01
    相关资源
    最近更新 更多