SMF icon indicating copy to clipboard operation
SMF copied to clipboard

Use reverse proxy IP for users

Open MarcoCLA opened this issue 2 years ago • 4 comments

The real client IP is not used in $user_info. This causes incorrect behavior when used behind a reverse proxy. For example only one guest will be visible (as only the IP of the reverse proxy is used) and all logging is linked to that IP.

Again a small hotfix. A better aproach would be to use a proper getClientIP() function which processes the headers and checks for the reverse proxy IP.

Example: Symphony getClientIP()

MarcoCLA avatar Mar 01 '22 19:03 MarcoCLA

This is the reason we have $user_info['ip'] and $user_info['ip2']. If incorrect stats/guests online are being detected because of a single ip, then we should be fixing that. In reality, guests online shouldn't be determined by their ip, but by their session. Some countries alone have a limited number of IPv4 and use what is essentially a CGNAT.

jdarwood007 avatar Mar 02 '22 00:03 jdarwood007

@MarcoCLA, please open an issue to describe in more detail the problem that this PR is meant to address.

Sesquipedalian avatar Mar 02 '22 21:03 Sesquipedalian

What is the use-case of $user_info['ip'] in the current implementation ($_SERVER['REMOTE_ADDR'])?

If a forwarded ip is verified, I see no reason to use the REMOTE_ADDR instead of the validated forwarded ip.

MarcoCLA avatar Mar 03 '22 17:03 MarcoCLA

Added to "The future" for further consideration. It will help a great deal if we are given a more fulsome description of the problem in a proper issue report.

Sesquipedalian avatar Apr 04 '22 17:04 Sesquipedalian