Answer the question
In order to leave comments, you need to log in
How to pass user IP to Nginx proxy?
There is a proxy on Nginx, config
server {
listen 80 default;
server_name _;
server_tokens off;
location / {
proxy_pass http://$http_host$request_uri;
proxy_set_header Host $http_host;
resolver 8.8.8.8;
proxy_set_header Accept-Encoding "";
proxy_hide_header Vary;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_http_version 1.0;
}
}
Answer the question
In order to leave comments, you need to log in
You will not be able to replace the proxy address with your own in any case.
You can send the real IP with an additional header to the server:
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
In proxy \ NAT mode, this cannot be done. Routing only, i.e. not nginx.
You need to pass the client address in the X-Real-IP header.
"By default" foreign web servers only accept this header from the localhost.
So you cannot organize such a proxy on other sites.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question