Using Nginx reverse proxy, how the backend Web obtains real client IP
One, Nginx reverse proxy nginx, the back end of Nginx How to configure to get to the client's real IP address it.
1. First, you need to add a row of parameters to the location on the configuration file nginx.conf on the Nginx Proxy server:
Proxy_set_header X-real-ip $remote _addr;
|
Restart Nginx Service
2. Configure the rear Nginx
vim/usr/local/nginx/conf/nginx.conf Add the following parameters:
Set_real_ip_from 192.168.88.133; #ip为nginx代理服务器的ip地址, this line needs to be added to HTTP, but outside the server |
Restart Nginx Service
The above configuration will be able to view the client's real IP address on the back-end Nginx server.
Second, Nginx reverse proxy Apache
1. On the proxy server Nginx configuration and reverse proxy nginx configuration is the same, reference 1-1, here will not repeat;
2. Configure Apache
Vim/usr/local/apache2/conf/httpd.conf Find the following
Logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" Combined
Modify the '%h' in this line to '%{x-real-ip}i'
Restart Nginx service can be;
The above configuration will be able to view the real client IP address on the back-end Apache.
This article from the "Shallow faint" blog, reproduced please contact the author!
Using Nginx reverse proxy, how the backend Web obtains real customer IP