nginx 配置中的批量/海量 410 页面

nginx 配置中的批量/海量 410 页面

我们有 130 个 URL(一些查询字符串)来提供正常的 404 页面,但是返回 410 标头。

该列表看起来就像是各种东西的混合体

https://www.example.com/blog/wp-loads.php?q=82
https://www.example.com/blog/wp-loads.php?q=94
https://www.example.com/mph
https://www.example.com/blog/example-football
https://www.example.com/blog/wp-loads.php?q=24
https://www.example.com/services/Email-marketing.htm
https://www.example.com/blog/2013/02/adaptive-vs-responsive-web-design
https://www.example.com/blog/2013/04/magic-with-css3
https://www.example.com/services/Digital-Creative-Services-Overview.htm
https://www.example.com/services/Email-Marketing.htm?__hstc=60812914.e835c34ab7bf88e972fdd7a7debc8575.1453680000065.1453680000066.1453680000067.1&__hssc=60812914.2.1453680000068&__hsfp=3972014050
https://www.example.com/blog/forums/forum/general-chat
https://www.example.com/blog/wp-loads.php?q=87
https://www.example.com/blog/2013/04/improved-targeting-with-google-adwords-enhanced-campaigns
https://www.example.com/blog/forums/topic/checking-out-the-forum
https://www.example.com/blog/forums/topic-tag/balloons-conduction-fun
https://www.example.com/blog/ramblings
https://www.example.com/blog/twelve-christmas-crackers
https://www.example.com/blog/a-new-awesome-pair-of-hands-in-the-client-services-team
https://www.example.com/services/motion-graphics-and-flash.htm
https://www.example.com/services/translation-services-and-website-copy.htm

我们正在尝试找出在 nginx conf 中批量处理 410 这些的最佳方法是什么?

谢谢

答案1

对于纯 URL,由于没有特别一致的东西,因此请创建一个包含如下条目的 conf 文件:

location ~ /blog/example-football { return 410; }

但是,位置块不会处理查询字符串。它们在变量中返回$args或在变量中命名$arg_name,因此如果您有需要返回 410 的特定查询 URI,请在服务器外部创建一个映射,如下所示:

map $arg_q $response {
    default 0;
    87 1;
    94 1;
    ...
}

然后在你的位置块中记住如果是邪恶的

location ~ /blog/wp-loads.php {

    if ($response = 1) {
         return 410;
    }
}

相关内容