Welcome Guest, Not a member yet? Register   Sign In
Amazon Load Balancing and CodeIgniter - $config['proxy_ips']
#1

[eluser]Eric Brown[/eluser]
It is well documented that amazon IPs change for load balancers as traffic goes up and down.
https://forums.aws.amazon.com/thread.jsp...adID=32280

I came across a fix but I'm not sure it meets my needs.
http://brettic.us/code/php-codeigniter-r...desyntax_2

Since I can turn the load balancer on or off depending on traffic spikes I'm trying to find an optimal way to use $config['proxy_ips'] to support this.

I clearly can't put an IP or list of IPs as I never know what they'll be at any time. I was thinking of trying to edit the code to support a range looking for anything under 10.*

Any thoughts around this would be greatly appreciated.

I'm using CI v1.7.2
#2

[eluser]magnushung[/eluser]
You may want to get the DNS and request the ip after it changes.
#3

[eluser]Eric Brown[/eluser]
Are you saying I should do a lookup for the dns on each request and then insert that IP into the proxy_ip array?
#4

[eluser]Eric Brown[/eluser]
An other thoughts here? Thanks for your help.
#5

[eluser]meattle[/eluser]
bump
#6

[eluser]Eric Brown[/eluser]
My simple fix was to assume every request was coming from the load balancer

Code:
$config['proxy_ips'] = $_SERVER["REMOTE_ADDR"];
#7

[eluser]meattle[/eluser]
Thanks Eric! By any chance do you know what do to about SSL requests? For regular http requests once can look at "x-forwarded-for-header" for the client IP address, but I'm having trouble figuring out what to do about HTTPS requests via ELB.
#8

[eluser]Eric Brown[/eluser]
I'm no expert, but not sure why SSL vs. Non-SSL would matter. We get a combination of HTTP/HTTPS requests and the data come over the same. We are able to see all request data in both cases.
#9

[eluser]meattle[/eluser]
For some reason AWS does not set the x-forwarded-for-header header for HTTPS requests, but it does for HTTP.
#10

[eluser]Eric Brown[/eluser]
This is all I have to use in my CI app
Code:
$this->x_forwarded_for = (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : null;


Since I implemented the fix above, there is always a value for XFF. Only on rare occasions when the requests are proxied do I get additional IPs in the chain. Are you serving up content directly to a device/browser or are you making server to server requests?




Theme © iAndrew 2016 - Forum software by © MyBB