Filtering out non-HTTP requests (400 errors)
merlin corey
merlincorey at dc949.org
Mon Jan 11 22:47:17 MSK 2010
On Mon, Jan 11, 2010 at 9:22 AM, Michael Shadle <mike503 at gmail.com> wrote:
> On Mon, Jan 11, 2010 at 8:28 AM, Grzegorz Nosek
> <grzegorz.nosek at gmail.com> wrote:
>
>> So, is there a simple way to filter out non-HTTP requests from the
>> access log? http://wiki.nginx.org/HWLoadbalancerCheckErrors doesn't seem
>> to work unfortunately (I tried something along this way already and
>> checked this exact config now).
>
> I have this as well, but from some hardware load balancer our provider uses.
>
> I want to have it basically say:
>
> if ($remote_addr ~* 10.2.34.3) {
> access_log off;
> }
>
> Or something of the nature. Note: that is pseudocode, I probably
> messed up the ~* but I just woke up. It was an example :)
>
> I think I tried this and it didn't work (and I'm sure Grzegorz tried it too)
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>
Not many things go well inside if aside from things defined in the
same module. The only way without hacking code that I can think to do
this is with some internal servers that you proxy to conditionally
based on IP address. It's dirty as hell, though XD -- example below
(untested so consider psuedoconfig):
upstream good {
server 127.0.0.1:1234;
}
upstream bad {
server 127.0.0.1:1235;
}
server {
listen 80;
server_name main_server;
server_name_in_redirect off;
access_log off;
set $backend good;
if ($remote_addr ~* 10.2.34.3) {
set $backend bad;
}
location / {
proxy_pass http://$backend;
}
}
server {
listen 127.0.0.1:1234;
server_name good;
.. good config ..
}
server {
listen 127.0.0.1:1235;
server_name bad;
.. bad config ..
}
-- Merlin
More information about the nginx
mailing list