Blocking IP's Nginx behind proxy

Posted by FunkyChicken on Server Fault See other posts from Server Fault or by FunkyChicken
Published on 2012-10-31T09:16:35Z Indexed on 2012/10/31 11:03 UTC
Read the original article Hit count: 253

Filed under:
|
|

I'm running a Nginx 1.2.4 webserver here, and I'm behind a proxy of my hoster to prevent ddos attacks. The downside of being behind this proxy is that I need to get the REAL IP information from an extra header. In PHP it works great by doing $_SERVER[HTTP_X_REAL_IP] for example.

Now before I was behind this proxy of my hoster I had a very effective way of blocking certain IP's by doing this: include /etc/nginx/block.conf and to allow/deny IP's there.

But now due to the proxy, Nginx sees all traffic coming from 1 IP.

Is there a way I can get Nginx to read the IP's like how PHP does, with the X-REAL-IP header?

© Server Fault or respective owner

Related posts about php

Related posts about nginx