nginx在varnish后端做负载均衡,后端tomca获取客户端真实IP
2015-06-10 15:21
651 查看
nginx在varnish后端做负载均衡,后端tomca获取客户端真实IP
1.设置nginx配置文件
首先要确定nginx做负载均衡,在安装时把http_realip_module 安装上了。
查看方法: /usr/local/nginx/sbin/nginx -V
配置nginx.conf
vim /usr/local/nginx/conf/nginx.conf
加入 set_real_ip_from 192.168.88.131;
重新加载nginx: /usr/local/nginx/sbin/nginx reload
2.设置varnish配置文件
vim /usr/local/varnish/etc/varnish/default.vcl
加入如下配置:
启动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
现在从后端的tomcat上获取客户端真实的IP地址了。。
本文出自 “浅浅的淡淡” 博客,请务必保留此出处http://cuixiang.blog.51cto.com/8204722/1660432
1.设置nginx配置文件
首先要确定nginx做负载均衡,在安装时把http_realip_module 安装上了。
查看方法: /usr/local/nginx/sbin/nginx -V
配置nginx.conf
vim /usr/local/nginx/conf/nginx.conf
加入 set_real_ip_from 192.168.88.131;
重新加载nginx: /usr/local/nginx/sbin/nginx reload
2.设置varnish配置文件
vim /usr/local/varnish/etc/varnish/default.vcl
加入如下配置:
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; } |
/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
现在从后端的tomcat上获取客户端真实的IP地址了。。
本文出自 “浅浅的淡淡” 博客,请务必保留此出处http://cuixiang.blog.51cto.com/8204722/1660432
相关文章推荐
- Linux环境下安装Nginx+Pcre+OpenSSL
- Nginx最新解析漏洞
- nginx报错:Permission denied
- keepalived+nginx实现nginx的高可用
- Nginx安全配置研究
- Nginx/LVS/HAProxy负载均衡软件的优缺点详解
- Nginx 战斗准备 —— 优化指南
- nginx 伪静态 rewrite
- nginx那些强大的不可不说的功能
- nginx第三方模块---nginx-sticky-module的使用(基于cookie的会话保持)
- nginx gzip压缩提升网站速度
- 通过已有Nginx镜像创建私有仓库
- Nginx自动安装脚本(比较简单,有待优化)
- Nginx(1):简介
- nginx学习(一)
- nginx问题解决
- 《转》使用nginx和php实时产生缩略图
- 使用Hive的正则解析器RegexSerDe分析nginx日志
- PHP加Nginx实现动态裁剪图片方案
- 使用DNS轮询+NGINX+PHP+NFS+MYSQL实现集群高可用