Nginx load balancer on varnish backend, backend TOMCA get client real IP
1. setting Nginx configuration file
First of all to determine the Nginx load balancing, installed in the installation of the Http_realip_module.
View method:/usr/local/nginx/sbin/nginx-v
Configure nginx.conf
Vim/usr/local/nginx/conf/nginx.conf
Join Set_real_ip_from 192.168.88.131;
Reload Nginx:/usr/local/nginx/sbin/nginx Reload
2. Setting the varnish configuration file
Vim/usr/local/varnish/etc/varnish/default.vcl
Add the following configuration:
Sub Vcl_recv { Remove Req.http.x-real-ip; Set req.http.x-real-ip = Client.ip; Set req.http.x-forwarded-for = Client.ip; } |
Start varnish:
/usr/local/varnish/sbin/varnishd-f/usr/local/varnish/etc/varnish/default.vcl-s file,/home/varnish_cace,1g-t 127.0.0.1:2000-a 0.0.0.0:80
Now get the real IP address of the client from the back-end tomcat.
This article from the "Shallow faint" blog, please be sure to keep this source http://cuixiang.blog.51cto.com/8204722/1660432
Nginx load balancer on varnish backend, backend TOMCA get client real IP