2

我有一个 wordpress 网站,即使我使用的是 disqus,我也经常收到很多垃圾邮件。什么是记录所有访问的 IPwp-comments-post.php并永久阻止它们(或立即阻止不记录)的好方法?删除/重命名文件可能是一个解决方案,但我想阻止它们,这样它们就不会回来了。我在 nginx 前面使用 apache 作为反向代理。我正在考虑通过 nginx/iptables 执行此操作,这样就不必再访问 apache。

4

2 回答 2

1

您可以使用 .htaccess 文件执行此操作

order allow,deny
deny from 192.168.44.201
deny from 224.39.163.12
deny from 172.16.7.92
allow from all

或阻止一个范围

order allow,deny
deny from 192.168.
deny from 10.0.0.
allow from all

甚至是 ISP

order allow,deny
deny from some-evil-isp.com
deny from subdomain.another-evil-isp.com
allow from all

将 htaccess 文件放在包含您的文件的目录中

于 2012-06-29T07:01:30.067 回答
1

我使用 lua 模块来阻止这些类型的用户,但它有点复杂。

您可以通过将以下位置块放在处理您的 php 的位置块之上或之内来简单地禁止访问该文件:

location ~* wp-comments-post\.php {
    return 403;
}
location ~* .+\.php {
    # PHP handling config
}

或者

location ~* .+\.php {
    location ~* wp-comments-post\.php {
        return 403;
    }
    # PHP handling config for others
}
于 2012-06-29T11:26:55.347 回答