环境根据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反向代理、根据浏览器分离访问的更多相关文章

  1. Nginx 反向代理功能-动静分离

    Nginx 反向代理功能-动静分离 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.

  2. nginx反向代理(动静分离)

    使用反向代理(动静分离)可以让nginx专注静态内容,把动态请求交给apache来处理,发挥各自的优势,而且整个架构更加清晰: 这里假设你已经搭建好了nginx环境; 为了简单起见,就不用源码编译安装 ...

  3. nginx反向代理前后端分离项目(后端多台)

    目前软件架构都比较流行前后端分离,前后端的分离也实现了前后端架构的分离,带来的好处 —— 整个项目的开发权重往前移,实现真正的前后端解耦,动态资源和静态资源分离,提高了性能和扩展性. 通常Spring ...

  4. Nginx反向代理之动静分离

    我们已经知道了什么是正向代理与反向代理,这次我们就讲一下Nginx的动静分离的案例,其实质运用的就是反向代理,专门用一台服务器代理服务器上的图片资源. 想使用代理必然要配置代理,配置反向代理,必须要用 ...

  5. nginx反向代理、动静分离

    环境:根据http://www.cnblogs.com/zzzhfo/p/6032095.html配置 方法一:根据目录实现动静分离 在web01创建image并上传一张图片作为静态页面 [root@ ...

  6. nginx反向代理tomcat访问时浏览器加载失败,出现 ERR_CONTENT_LENGTH_MISMATCH 问题

    问题说明:测试机上部署了一套业务环境,nginx反向代理tomcat,在访问时长时间处于加载中,十分缓慢! 通过浏览器调试(F12键->Console),发现有错误ERR_CONTENT_LEN ...

  7. nginx反向代理vue访问时浏览器加载失败,出现 ERR_CONTENT_LENGTH_MISMATCH 问题

    问题说明:测试机上部署了一套业务环境,nginx反向代理tomcat,在访问时长时间处于加载中,十分缓慢! 通过浏览器调试(F12键->Console),发现有错误ERR_CONTENT_LEN ...

  8. Nginx反向代理+负载均衡简单实现(http方式)

    1)nginx的反向代理:proxy_pass2)nginx的负载均衡:upstream 下面是nginx的反向代理和负载均衡的实例: 负载机:A机器:103.110.186.8/192.168.1. ...

  9. nginx 反向代理 负载均衡

    nginx反向代理 用户(浏览器) 请求网站资源 -> 直接定位到django后台(所有的请求压力,都直接给了后台) django默认对并发性 很差,并且处理网页的静态资源,效率很差 10万个并 ...

  10. Nginx反向代理的简单实现

    1)nginx的反向代理:proxy_pass2)nginx的负载均衡:upstream 下面是nginx的反向代理和负载均衡的实例: 负载机:A机器:103.110.186.8/192.168.1. ...

随机推荐

  1. Objective-C学习笔记之for( int )机制

    NSArray *myArray = [NSArray arrayWithObjects:@"1",@"2",@"3",@"4&q ...

  2. js 正则表达式提取内容

    var wlan = /([a-zA-Z0-9]+)\s+Scan completed :/ var current_wlan="" if (line.match("Sc ...

  3. PHP实现观察者模式

    <?php //php设计模式观察者模式 /** 被观察者 */ class user implements SplSubject{ public $lognum; public $hobby; ...

  4. JavaWeb学习笔记——JSP标准标签库JSTL

  5. Envelope Letter

    http://www.thefullwiki.org/More_C%2B%2B_Idioms/Envelope_Letter http://www.smallmemory.com/almanac/Co ...

  6. ecshop 如果缩略图为空,使用默认图片

    引用:$row['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); lib_common.php /** * 重新获 ...

  7. 为你的Visual Studio单独设置代理服务器

    http://blog.sina.com.cn/s/blog_58c506600101tycn.html 最近,因为国内访问Visual Studio Online(微软的免费代码托管服务,以前叫Te ...

  8. yii2接收activeform表单信息

    第一种方法: $model->load(Yii::$app->request->post()); 第二种方法: 获取具体的某一项的值 $demo = $_POST['模型名']['字 ...

  9. yii2中事务不能回滚的解决

    $player1 = Player::findOne(1); $player1->nickname = '111'; $player2 = Player::findOne(2); $player ...

  10. linux中Jetty的安装和配置

    Jetty Jetty 是一个开源的servlet容器,它为基于Java的web内容,例如JSP和servlet提供运行环境.Jetty是使用Java语言编写的,它的API以一组JAR包的形式发布.开 ...