Closed runnermatthew closed 1 year ago
This is not a bug.
Environment variables are not PHP variables.
dotenv dose not support array like this:
app.proxyIPs = ['172.25.0.1/16'=>'X-Forwarded-For']
Why don't you set them in the Config file?
Workaround is to add the constructor in Config\App
, and set $proxyIPs
from environment variables.
Why don't you set them in the Config file?
I'd like to limit the configuration of each stack to their dotenv file.
Workaround is to add the constructor in
Config\App
, and set$proxyIPs
from environment variables.
This is the route I'll take. Thank you for the suggestion.
PHP Version
8.0
CodeIgniter4 Version
4.2.11
CodeIgniter4 Installation Method
Composer (as dependency to an existing project)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
PostgreSQL 13.9
What happened?
4.2.11 set the following requirement for in Config/App.php for
public $proxyIPs
CodeIgniter4 has no way to set arrays from dotenv. This forces an App.php config file in addition to dotenv for each deploy.
Steps to Reproduce
In Config/App.php set
public $proxyIPs = [];
In dotenv set
app.proxyIPs =['172.25.0.1/16'=>'X-Forwarded-For']
where172.25.0.1/16
covers your reverse proxy IPs.$request->getIPAddress()
still returns proxy IP addressExpected Output
$request->getIPAddress()
to return the IP set by the proxy server in the X-Forwarded-For header.Anything else?
No response