Reward counts on a new server

coffee

New Member
Jul 23, 2014
83
0
0
I opened a ticket on this last week, so I'll post the answer here if it's solved in the ticket before here for anyone else that might run into this error.

I added a new server, but rewards are not counted on it. I tried adding the plugin files again, but to no avail. Also tried disabling it and re-enabling.

I have 4 tiers. All downloads count as the last tier and say IP limit reached and add $0 to rewards.

The rewards still count properly on the other file server.

Anyone run into this and know a fix?
 

coffee

New Member
Jul 23, 2014
83
0
0
Yup they're on the file server. I'd feel pretty crazy right now if they weren't :p
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
We managed to fix this one. For anyone else having the same issue the cause was Nginx to Apache in proxy mode. As Apache actually handles the file download it was seeing the users IP address and the Nginx server. So rewards weren't being counted based on the users IP/country.

To fix, ensure Nginx is forwarding the users real IP to Apache with this in the Nginx config:

Code:
proxy_set_header   X-Real-IP  $remote_addr;
Then amend /core/includes/coreFunctions.class.php. Replace the entire 'getUsersIPAddress()' function with this:

Code:
static function getUsersIPAddress()
    {
        // cloudflare
        if ((isset($_SERVER['HTTP_CF_CONNECTING_IP'])) && strlen($_SERVER['HTTP_CF_CONNECTING_IP']))
        {
            return $_SERVER['HTTP_CF_CONNECTING_IP'];
        }

        // for nginx proxy to apache users
        if ((isset($_SERVER['HTTP_X_REAL_IP'])) && strlen($_SERVER['HTTP_X_REAL_IP']))
        {
            return $_SERVER['HTTP_X_REAL_IP'];
        }

        return $_SERVER['REMOTE_ADDR'];
    }
The above code change will be part of the v4.0.1 release.