Simple Machines Community Forum

SMF Development => Feature Requests => Applied or Declined Requests => Aiheen aloitti: Myron Davis - joulukuu 21, 2007, 04:58:08 IP

Otsikko: support for trusted reverse proxies such as pound, squid, or other WAF.
Kirjoitti: Myron Davis - joulukuu 21, 2007, 04:58:08 IP
Make the following code change to the smf/Sources/Load.php file around line 441.  I would request the developers include this but reference a variable which can be set in a config file, if the variable is set use the code so it will be easy for people to support this.  This seems to work fine for me although there may be other places where this change is necessary.

Thanks,

-Myron


                        /* If the REMOTE_ADDR is the trusted reverse proxy and the HTTP_X_FORWARDED_FOR IP address is not blank use that IP address
instead of the REMOTE_ADDR replace 1.1.1.1 with your trusted reverse proxy */
                        if ($_SERVER['REMOTE_ADDR'] == "1.1.1.1" && !empty($_SERVER['HTTP_X_FORWARDED_FOR']))
                        {
                        /* Here lets log the HTTP_X_FORWARDED_FOR IP address if the connection came from a trust IP address*/
                        updateMemberData($ID_MEMBER, array('ID_MSG_LAST_VISIT' => (int) $modSettings['maxMsgID'], 'lastLogin' => time(), 'memberIP' => '\'' . $_SERVER['HTTP_X_FORWARDED_FOR'] . '\'', 'memberIP2' => '\'' . $_SERVER['BAN_CHECK_IP'] . '\''));

                        }
                        else
                        {
                                updateMemberData($ID_MEMBER, array('ID_MSG_LAST_VISIT' => (int) $modSettings['maxMsgID'], 'lastLogin' => time(), 'memberIP' => '\'' . $_SERVER['REMOTE_ADDR'] . '\'', 'memberIP2' => '\'' . $_SERVER['BAN_CHECK_IP'] . '\''));
                                }