Hits: 6757  

I was working on “Private AWS Cloudfront Distribution” for AWS Elastic Load Balancer (ELB), allowing our application servers private access to our AWS cloudfront.

But PHP Server Environment Variable $_SERVER["REMOTE_ADDR"] is displaying suspicious results, it really tedious to get remote host client IP behind ELB :(

Now we have 2 options…

1. mod_rpaf and Amazon ELB
http://tech.superhappykittymeow.com/?p=281
http://giantdorks.org/alain/easily-get-the-correct-client-ip-with-mod_rpaf/

if ($_SERVER["HTTP_X_FORWARDED_FOR"]) {
$realclientip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else {
$realclientip = $_SERVER["REMOTE_ADDR"];
}

2. %{X-Forwarded-For}i from Apache Log (Time Consuming)
http://blog.kenweiner.com/2009/09/amazon-elb-capturing-client-ip-address.html
https://forums.aws.amazon.com/message.jspa?messageID=216977

You Apache log format would then look something like this:
LogFormat “\”%{X-Forwarded-For}i\” %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-agent}i\”" combined-elb
CustomLog log/acces_log combined-elb

Apache Module mod_remoteip

PHP: $_SERVER["HTTP_X_FORWARDED_FOR"]
PHP: $_SERVER["HTTP_X_CLUSTER_CLIENT_IP"]

$_SERVER['REMOTE_ADDR']; Apache Enviromental Variable is not working on your server :)

http://php.net/manual/en/function.getenv.php

http://www.zytrax.com/tech/web/env_var.htm



Tagged with:  
  • http://www.hostv.com/ red5 hosting

    ELB is a good balancer. Red5
    Hosting gives many solutions for the customers. Every type of
    details can be used through on the internet. It is a worldwide program. 

  • http://www.hostv.com/ red5 hosting

    ELB is a good balancer. Red5
    Hosting gives many solutions for the customers. Every type of
    details can be used through on the internet. It is a worldwide program. 

  • Pandurangan Jayaraj

    is there any to configure in IIS 7 to get the ELB Logs 

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...