zoukankan      html  css  js  c++  java
  • nginx*、根据浏览器分离访问

    环境根据http://www.cnblogs.com/zzzhfo/p/6032095.html配置

    修改LB的/usr/local/nginx/conf/nginx.conf

    upstream static_pools {
         server 192.168.119.130:80;
    }   
    upstream dynamic_pools {
         server 192.168.119.133:80;
    }
    
        server {
            listen       80;
            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" - - [07/Oct/2016:22:35:07 +0800] "GET /favicon.ico HTTP/1.0" 404 290 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
    "192.168.119.1" - - [07/Oct/2016:22:36:17 +0800] "GET /test.html HTTP/1.0" 200 8 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
    "192.168.119.1" - - [07/Oct/2016:22:51:37 +0800] "GET /test.html HTTP/1.0" 200 8 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
    "192.168.119.1" - - [07/Oct/2016:22:56:05 +0800] "GET /test.html HTTP/1.0" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
    "192.168.119.1" - - [07/Oct/2016:22:56:06 +0800] "GET /test.html HTTP/1.0" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
    "192.168.119.1" - - [07/Oct/2016:22:56:06 +0800] "GET /test.html HTTP/1.0" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
    "192.168.119.1" - - [07/Oct/2016:22:56:07 +0800] "GET /test.html HTTP/1.0" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
    "192.168.119.1" - - [07/Oct/2016:22:56:08 +0800] "GET /test.html HTTP/1.0" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
    "192.168.119.1" - - [07/Oct/2016:22:56:09 +0800] "GET /test.html HTTP/1.0" 304 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0"
    "192.168.119.1" - - [07/Oct/2016:22:56:09 +0800] "GET /test.html HTTP/1.0" 304 - "-" "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" - - [07/Oct/2016:22:46:28 +0800] "GET /test.html HTTP/1.0" 304 - "-" "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" - - [07/Oct/2016:22:46:29 +0800] "GET /test.html HTTP/1.0" 304 - "-" "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" - - [07/Oct/2016:22:46:29 +0800] "GET /test.html HTTP/1.0" 304 - "-" "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" - - [07/Oct/2016:22:46:29 +0800] "GET /test.html HTTP/1.0" 304 - "-" "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" - - [07/Oct/2016:22:46:30 +0800] "GET /test.html HTTP/1.0" 304 - "-" "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" - - [07/Oct/2016:22:46:30 +0800] "GET /test.html HTTP/1.0" 304 - "-" "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" - - [07/Oct/2016:22:46:30 +0800] "GET /test.html HTTP/1.0" 304 - "-" "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" - - [07/Oct/2016:22:46:30 +0800] "GET /test.html HTTP/1.0" 304 - "-" "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" - - [07/Oct/2016:22:56:40 +0800] "GET /test.html HTTP/1.0" 200 3 "-" "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" - - [07/Oct/2016:22:56:41 +0800] "GET /test.html HTTP/1.0" 304 - "-" "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)"
  • 相关阅读:
    数据库事务隔离级别+Spring 声明性事务隔离级别
    (面试题)如何查找Oracle数据库中的重复记录
    Spring提供的线程池支持--百度文库
    (面试题)输出下列程序结果(考察字符串与其他类型+连接)
    (面试)有两个木桶,一个3斤,一个5斤,水无限,要怎么样得到精确地4斤水
    (面试)涉及到继承和类加载
    (面试题)用折半查找法在一组整形数组中查找某个数据
    (面试)写出下面switch语句的输出结果
    HTML 鼠标坐标和元素坐标
    HTML5 元素属性介绍
  • 原文地址:https://www.cnblogs.com/hwlong/p/6063292.html
Copyright © 2011-2022 走看看