Nginx load balancer on varnish backend, backend TOMCA get client real IP

Source: Internet
Author: User
Tags varnish nginx load balancing


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.