Welcome! Log In Create A New Profile

Advanced

Nginx "limit_req_zone" behind Amazon's ELB: How to evaluate the remote IP?

Posted by Brian1968 
Nginx "limit_req_zone" behind Amazon's ELB: How to evaluate the remote IP?
February 26, 2013 04:36PM
Hi,

I'm using Nginx 1.1.19 installed in my hosts which are behind the ELB (elastic load balancer) in Amazon's cloud. I'm trying to use the "limit_req_zone" command to throttle the requests. What should this command evaluate to have access to the real remote IP?

This is the default way to use the command:
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

But "$binary_remote_addr" will bring the ELB's IP, not the client's IP.

I'm trying this now:
limit_req_zone $http_x_forwarded_for zone=...............

and it seems that it is working, but I'm not sure this will always work. I haven't seen anybody suggesting this approach, and haven't read it in any documentation so as to trust it will really work.

Or should I use the directives "set_real_ip_from" and "real_ip_header"? I read that is the way to do it, but it seems that those directives require the "ngx_http_limit_req_module" module, which seems that doesn't come with the normal installation of Nginx, and I don''t have any idea of how to install it with extra modules thet didn't come originally.

What is the right way to do this? I guess I'm not the first one to use Nginx behaind ELB, so I bet there must be an "official" way to do this.

By the way: I'm using Ubuntu 12.04.1, which brings Nginx 1.1.19.

Thanks in advance!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 308
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready