CodeIgniter Forums
Best way to rewrite and/or extend requests [SOLVED] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: Best way to rewrite and/or extend requests [SOLVED] (/showthread.php?tid=81498)



Best way to rewrite and/or extend requests [SOLVED] - superior - 03-12-2022

Hi,

I'm rewriting my project to CodeIgniter 4 previously build in CodeIgniter 3, this project has always been behind Cloudflare to protect certain information and for security reasons.
Cloudflare rewrites the REMOTE_ADDR to an IP the visitor is send on by proxy, but they also send the visitors IP with HTTP_CF_CONNECTING_IP so we can still see what address is connecting.

I could write a helper but the system is also relying on REMOTE_ADDR for example in sessions, so that would be a massive workaround.
Is there a propper way to extend the class/method so I can set a different server global if this global is available?


EDIT:
--------------------------------------------
Found the solution, this should be done in App\Config::proxyIPs.
Created a different config to get IP-addresses provided by Cloudflare through text files (IPv4 & IPv6).
I'm storing this information inside a cache file refreshed daily so it can read any changes as well.


RE: Best way to rewrite and/or extend requests - InsiteFX - 03-13-2022

Please edit your Post Title and add [SOLVED] to the end of it.


RE: Best way to rewrite and/or extend requests [SOLVED] - superior - 03-13-2022

(03-13-2022, 01:03 AM)InsiteFX Wrote: Please edit your Post Title and add [SOLVED] to the end of it.

Done, thank you :-)