Post by pradeepn » Wed Aug 17, 2011 3:52 am

When OpenCart is deployed behind a load balancer, the Client IP address shows the load balancer's IP address.
OpenCart should get the real client IP address looking at the HTTP_X_FORWARDED_FOR instead of REMOTE_ADDR.

It would be nice to first look at HTTP_CLIENT_IP, then HTTP_X_FORWARDED_FOR and then REMOTE_ADDR.

A snippet of code that would do this is described in the is article:
http://www.programmingfacts.com/visitor ... dress-php/

Thanks

Newbie

Posts

Joined
Fri Jul 08, 2011 9:12 am

Post by pradeepn » Wed Aug 17, 2011 4:04 am

The following files seems to be using the REMOTE_ADDR from the request.

./admin/controller/common/forgotten.php
./catalog/controller/payment/authorizenet_aim.php
./catalog/controller/payment/pp_pro_uk.php
./catalog/controller/payment/sagepay_direct.php
./catalog/controller/payment/perpetual_payments.php
./catalog/controller/payment/authorizenet_sim.php
./catalog/controller/payment/pp_pro.php
./catalog/controller/checkout/confirm.php
./system/library/affiliate.php
./system/library/customer.php
./system/library/user.php

Newbie

Posts

Joined
Fri Jul 08, 2011 9:12 am

Post by pradeepn » Thu Aug 18, 2011 3:31 am

Thanks to vqmod. Attached is the vqmod xml file to get the real client IP address if you are running behind a load balancer or proxy.

(Note: you will need to install vqmod (http://vqmod.com/) first. Then drop the attached .xml file into the xml directory, that will mod all instances of $this->request->server['REMOTE_ADDR'] with a function that will get the real client IP. This will work with or without a load balancer (or proxy).

(Needless to say, backup and use at your own risk. It has been tested to work fine on my site).

Cheers

Attachments


Newbie

Posts

Joined
Fri Jul 08, 2011 9:12 am

Post by zstergios » Mon May 18, 2020 9:44 pm

You can use this VQMOD
https://github.com/zstergios/Opencart-2.x-APCU-Caching/ (there is for 1.5 version too)

It adds
APCU support
VQMOD for Nginix/Varnish support (or Engintron) - Cache control
Cache VQMOD products and categories
IP Fix VQMOD

Newbie

Posts

Joined
Tue Mar 19, 2019 1:15 am
Who is online

Users browsing this forum: No registered users and 8 guests