Page 1 of 1
Real Client IP Address
Posted: Wed Aug 17, 2011 3:52 am
by pradeepn
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
Re: Real Client IP Address
Posted: Wed Aug 17, 2011 4:04 am
by pradeepn
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
Re: Real Client IP Address - solution using vqmod
Posted: Thu Aug 18, 2011 3:31 am
by pradeepn
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
Re: Real Client IP Address
Posted: Mon May 18, 2020 9:44 pm
by zstergios
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