It has to print the remote IP from where the request originated
Prints internal Nginx proxy IP
| Q | A |
| --- | --- |
| Yii version | 2.0.9 |
| PHP version | 5.6.20 |
| Operating system | Ubuntu 14.04 |
That's by design. If you need it to return IP passed via HTTP header you should override the method. The reason is that by default HTTP-headers could be modified by user.
Shouldn't there be a way to do this from the framework itself? For example, the default behaviour can be to return $_SERVER['REMOTE_ADDR']
like it is now, but also allow the programmer to pass a list of trusted headers which contain the real client IP. These header fields would then take precedence over $_SERVER['REMOTE_ADDR']
@krukru this is discussed in https://github.com/yiisoft/yii2/issues/10854
Most helpful comment
That's by design. If you need it to return IP passed via HTTP header you should override the method. The reason is that by default HTTP-headers could be modified by user.