Real IP and PORT of User


i need the real IP and PORT of the User:

so i use → $_SERVER[“HTTP_CF_CONNECTING_IP”] instead of $_SERVER[REMOTE_ADDR] and it works like a charm for the IP.

BUT, i can’t find the equivalent to $_SERVER[REMOTE_PORT] :frowning:

How i get the real Port of the user?

You can use Transform Rules to add a header (e.g. X-Client-Port) containing the real client port.


Hey Albert, thank you very much for your effort and quick reply :slight_smile:

But unfortunately i doesn’t work :frowning:

When i using “echo $_SERVER[“X-Client-Port”]:” its empty.

You have an Idea?

So I personally haven’t used PHP but I believe you need to use $_SERVER["HTTP_X_CLIENT_PORT"].

Also, just use true as the expression. That will make sure it always runs.

1 Like

hey, yes that’s true :slight_smile: now it works. thank you very much :slight_smile:

ps: if anybody is looking for other variables… just print_r (print_r ($_SERVER)) on the whole $_SERVER array and yo get a nice list of all available “options”.


PS: if you want to verify that the given port is correct → u can use this handy commandline tool:

sudo tcptrack -i

in my case: in every single request Cloudflare had given back the right / real user port

and keep in mind: port can change every single request… so i might look like a random number :wink:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.