nginx反向代理、根据浏览器分离访问
环境根据http://www.cnblogs.com/zzzhfo/p/6032095.html配置
修改LB的/usr/local/nginx/conf/nginx.conf
upstream static_pools {
server 192.168.119.130:;
}
upstream dynamic_pools {
server 192.168.119.133:;
}
server {
listen ;
server_name www.test.com;
location / {
root html;
index index.html index.htm;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if ($http_user_agent ~* "MSIE") #MSIE IE浏览器
{
proxy_pass http://dynamic_pools;
}
if ($http_user_agent ~* "Firefox") #Firefox火狐浏览器
{
proxy_pass http://static_pools;
}
}
在web01和web02上分别创建一个测试页
web01
[root@web01 www]# echo Firefox > test.html
web02
[root@web02 www]# echo "IE" > test.html
测试、分别使用Firefox和IE浏览器访问
Firefox访问(物理机没有做hosts解析使用LB的IP访问)


查看日志
web01
[root@web01 www]# tail -f /etc/httpd/logs/www.test.com.access_log
"192.168.119.1" - - [/Oct/::: +] "GET /favicon.ico HTTP/1.0" "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
"192.168.119.1" - - [/Oct/::: +] "GET /test.html HTTP/1.0" "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
"192.168.119.1" - - [/Oct/::: +] "GET /test.html HTTP/1.0" "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
"192.168.119.1" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
"192.168.119.1" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
"192.168.119.1" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
"192.168.119.1" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
"192.168.119.1" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
"192.168.119.1" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
"192.168.119.1" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
web02
[root@web02 www]# tail -f /etc/httpd/logs/www.test.com.access_log
"192.168.119.136" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
"192.168.119.136" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
"192.168.119.136" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
"192.168.119.136" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
"192.168.119.136" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
"192.168.119.136" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
"192.168.119.136" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
"192.168.119.136" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
"192.168.119.136" - - [/Oct/::: +] "GET /test.html HTTP/1.0" "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
"192.168.119.136" - - [/Oct/::: +] "GET /test.html HTTP/1.0" - "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
nginx反向代理、根据浏览器分离访问的更多相关文章
- Nginx 反向代理功能-动静分离
Nginx 反向代理功能-动静分离 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.
- nginx反向代理(动静分离)
使用反向代理(动静分离)可以让nginx专注静态内容,把动态请求交给apache来处理,发挥各自的优势,而且整个架构更加清晰: 这里假设你已经搭建好了nginx环境; 为了简单起见,就不用源码编译安装 ...
- nginx反向代理前后端分离项目(后端多台)
目前软件架构都比较流行前后端分离,前后端的分离也实现了前后端架构的分离,带来的好处 —— 整个项目的开发权重往前移,实现真正的前后端解耦,动态资源和静态资源分离,提高了性能和扩展性. 通常Spring ...
- Nginx反向代理之动静分离
我们已经知道了什么是正向代理与反向代理,这次我们就讲一下Nginx的动静分离的案例,其实质运用的就是反向代理,专门用一台服务器代理服务器上的图片资源. 想使用代理必然要配置代理,配置反向代理,必须要用 ...
- nginx反向代理、动静分离
环境:根据http://www.cnblogs.com/zzzhfo/p/6032095.html配置 方法一:根据目录实现动静分离 在web01创建image并上传一张图片作为静态页面 [root@ ...
- nginx反向代理tomcat访问时浏览器加载失败,出现 ERR_CONTENT_LENGTH_MISMATCH 问题
问题说明:测试机上部署了一套业务环境,nginx反向代理tomcat,在访问时长时间处于加载中,十分缓慢! 通过浏览器调试(F12键->Console),发现有错误ERR_CONTENT_LEN ...
- nginx反向代理vue访问时浏览器加载失败,出现 ERR_CONTENT_LENGTH_MISMATCH 问题
问题说明:测试机上部署了一套业务环境,nginx反向代理tomcat,在访问时长时间处于加载中,十分缓慢! 通过浏览器调试(F12键->Console),发现有错误ERR_CONTENT_LEN ...
- Nginx反向代理+负载均衡简单实现(http方式)
1)nginx的反向代理:proxy_pass2)nginx的负载均衡:upstream 下面是nginx的反向代理和负载均衡的实例: 负载机:A机器:103.110.186.8/192.168.1. ...
- nginx 反向代理 负载均衡
nginx反向代理 用户(浏览器) 请求网站资源 -> 直接定位到django后台(所有的请求压力,都直接给了后台) django默认对并发性 很差,并且处理网页的静态资源,效率很差 10万个并 ...
- Nginx反向代理的简单实现
1)nginx的反向代理:proxy_pass2)nginx的负载均衡:upstream 下面是nginx的反向代理和负载均衡的实例: 负载机:A机器:103.110.186.8/192.168.1. ...
随机推荐
- JS中的"=="转换规则
number类型与string类型比较,string会转换为number类型 '' == '0' //false 0 == ''//true; 0 == '0'//true ' \t\r\n '==0 ...
- JS-百钱买百鸡案例-for循环制作
<html> <head> <meta charset="utf-8"/> <title></title> <sc ...
- BZOJ4522: [Cqoi2016]密钥破解
pollard's rho模板题. 调参调到160ms无能为力了,应该是写法问题,不玩了. #include<bits/stdc++.h> using namespace std; typ ...
- mysql查询区分大小写
Mysql默认查询是不分大小写的,可以在SQL语句中加入 binary来区分大小写: BINARY不是函数,是类型转换运算符,它用来强制它后面的字符串为一个二进制字符串,可以理解为在字符串比较的时候区 ...
- Spring事务传播简介
一.事务传播属性(propagation) 1.REQUIRED,默认属性 此级别下,会为每一个调用的方法创建一个逻辑事务域,如果前面的方法已经创建了事务,那么后面的方法支持当前事务,如果当前没有事务 ...
- VC----SDK下对窗口非客户区的操作
窗口分成两大部分:客户区和非客户区.非客户区再次细分:标题栏,如图片中顶部深蓝色:左边框,如图片中红色部分:上边框,如图片中绿色部分:右边框,如图片中右侧天蓝色部分:底边框,如图片中下面棕色部分. 之 ...
- push submodule
git status git add sparx git commit -m "message" git push
- 大学站防SQL注入代码(ASP版)
方法1: Replace过滤字符 解决方法:查找login.asp下的<from找到下边的类似username=request.Form(”name”) pass=request.Form(”p ...
- Linux下删除命令
linux删除目录很简单 使用rm -rf命令即可.直接rm就可以了,不过要加两个参数-rf 即:rm -rf 目录名字(警告:不作任何提示,且不可恢复,不要说没提醒哦!严重警告!!!)-r 就是向下 ...
- yii2.0-advanced 高级版项目搭建
(一) 原文地址:http://www.yii-china.com/post/detail/1.html (二) 原文地址:http://www.yii-china.com/post/detail/2 ...