Welcome Guest, Not a member yet? Register   Sign In
Best way to rewrite and/or extend requests [SOLVED]
#1

(This post was last modified: 03-13-2022, 05:37 AM by superior.)

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.
Reply
#2

Please edit your Post Title and add [SOLVED] to the end of it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

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

Done, thank you :-)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB