我可以使用什么正则expression式来标识nginx日志中的无效文件请求?

我需要帮助为fail2banconfiguration正则expression式。 我使用我的networking服务器主要用于简单的播客文件托pipe,但我看到很多无效的请求在日志中的PHP,ASP和PL文件。

我想configurationfail2ban在日志中查找这些types的无效文件请求。

有一点,我有以下正则expression式string设置为Apache:

[[] client []](没有这样的文件或目录脚本未find或无法统计):/\S*(php|mysql|.asp|.exe|.pl)

[[] client []] script'/\S*(.php|.asp|.exe|.pl)\S*'not found or unable to stat * $

这显然不适用于nginx日志。 这是一个不良文件请求的摘录(我改变了path和IP):

2011/05/14 20:38:20 [error] 5349#0:* 828 open()“/example/path/htdocs/administrator.php”failed(2:No such file or directory),client:123.123.123.123 ,server:example.server.com,请求:“GET administrator.php HTTP / 1.1”,主机:“example.server.com”

我可以得到一些帮助制定修正正则expression式string来捕捉这些types的错误? 我想重申,我不主持任何PHP或ASP文件,所以我不太在意这里可能的误报风险。

/etc/fail2ban/filter.d/nginx-noscript.conf

 [Definition] failregex = open\(\) "/\S*(\.php|\.asp|\.exe|\.pl)\S*" failed \(2: No such file or directory\), client: <HOST>,.* ignoreregex = 

/etc/fail2ban/jail.conf

 [nginx-iptables] enabled = true filter = nginx-noscript action = iptables[name=nginx, port=81, protocol=tcp] logpath = /var/log/nginx/*error_log maxretry = 3 

注释掉ignoreip = 127.0.0.1/8并用一些不存在的请求进行testing:

2012/08/10 09:28:11 [error] 3473#0: *27 open() "/var/www/localhost/htdocs/d.pl" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /d.pl HTTP/1.0", host: "localhost:81"

/var/log/fail2ban.log ,你会看到如下所示:

 2012-08-10 09:32:55,234 fail2ban.actions: WARNING [nginx-iptables] Ban 127.0.0.1 

再次检查iptables:

 Chain fail2ban-nginx (1 references) pkts bytes target prot opt in out source destination 0 0 DROP all -- * * 127.0.0.1 0.0.0.0/0