Post by tanzilahmed » Mon May 25, 2015 2:06 pm

I have a server on which NGinx is installed.

Now the problem is that visitors ip is shown as my server ip please guide what to do in this regard?

Newbie

Posts

Joined
Sun May 24, 2015 2:22 pm

Post by tanzilahmed » Mon May 25, 2015 9:01 pm

Any one?

Newbie

Posts

Joined
Sun May 24, 2015 2:22 pm

Post by OpenTeam » Tue May 26, 2015 2:20 am

Hello,

Opencart uses

Code: Select all

$this->request->server['REMOTE_ADDR'];
to retrieve the IP of the visitor.

However, when using Nginx, it is normal that it is returning the machine IP using the above code.


SOLUTION

Edit your nginx.conf file which is normally located on '/etc/nginx' and add the following line:

Code: Select all

proxy_set_header        X-Real-IP       $remote_addr;
You will need to reload Nginx.

Then go to 'catalog/controller/common/footer.php' and replace the line below:

Code: Select all

$ip = $this->request->server['REMOTE_ADDR'];
with

Code: Select all

$ip = $this->request->server['HTTP_X_REAL_IP'];

Hope it helps you.

User avatar
Active Member

Posts

Joined
Tue May 19, 2015 2:31 am

Post by tanzilahmed » Thu May 28, 2015 2:56 pm

Thank you for your reply the hosting people has resolved this problem by themselves any ways very helpful to get this reply.

Newbie

Posts

Joined
Sun May 24, 2015 2:22 pm
Who is online

Users browsing this forum: Semrush [Bot] and 21 guests