3

I am using Nginx with Odoo, And I tried to get user ip address :

Without Nginx this Block of code

request.httprequest.environ['REMOTE_ADDR']

returns the user's ip_address

But with Nginx, it returns

127.0.0.1

and its normal, if Someone can help, I want to get the real IP address on Odoo

This is my Nginx Conf :

location / {
    proxy_pass http://127.0.0.1:7777;
    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header REMOTE_ADDR $remote_addr;
}
4

1 回答 1

0

Try querying X-real-IP

change your code to this:

request.httprequest.environ['HTTP_X_REAL_IP']
于 2016-04-04T15:18:18.700 回答