Skip to content
Browse files

Merge pull request #677 from ericcholis/dev

Add support for X-Real-Ip header (from nginx)
  • Loading branch information...
2 parents dc210f6 + 1caf8a0 commit d8625c5442461b4fd65efb41e58c96884bef4453 @nateabele nateabele committed
Showing with 7 additions and 1 deletion.
  1. +1 −1 action/Request.php
  2. +6 −0 tests/cases/action/RequestTest.php
View
2 action/Request.php
@@ -246,7 +246,7 @@ public function env($key) {
$this->_env[$key] = $val;
if ($key == 'REMOTE_ADDR') {
- foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_PC_REMOTE_ADDR') as $altKey) {
+ foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_PC_REMOTE_ADDR', 'HTTP_X_REAL_IP') as $altKey) {
if ($addr = $this->env($altKey)) {
$val = $addr;
break;
View
6 tests/cases/action/RequestTest.php
@@ -137,6 +137,12 @@ public function testRemoteAddr() {
$request = new Request(array('env' => array(
'REMOTE_ADDR' => '123.456.789.000',
+ 'HTTP_X_REAL_IP' => '111.222.333.444'
+ )));
+ $this->assertEqual('111.222.333.444', $request->env('REMOTE_ADDR'));
+
+ $request = new Request(array('env' => array(
+ 'REMOTE_ADDR' => '123.456.789.000',
'HTTP_X_FORWARDED_FOR' => '111.222.333.444',
'HTTP_PC_REMOTE_ADDR' => '222.333.444.555'
)));

0 comments on commit d8625c5

Please sign in to comment.
Something went wrong with that request. Please try again.