Hi there, we often have the situation where the userIP address is not correctly forwarded to the
Yii::$app->request->userIp method. There are a few configuration options available in
yii\web\Request. I also found a few GitHub issues around this topic but i want to have a forum post to make it clear and maybe help others struggling as well.
In our example we are using DigitalOceans App Platform. So the app is running behind an unknown load balancer ip and the user ip is provided in a variable called
HTTP_DO_CONNECTING_IP. So i came up with the following solution:
'request' => [ 'class' => 'yii\web\Request', 'ipHeaders' => ['HTTP_DO_CONNECTING_IP'], 'trustedHosts' => [ $_SERVER['REMOTE_ADDR'], ] ]);
Is there a better solution for that problem or is this the “best practice” solution? As mentioned, we do not know the load balancer IP, therefore using