• 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)"
  • 相关阅读:
    易语言常用源码
    ci的数据库地址
    格式化输出php数组
    mysql插入表情问题
    线程、进程与协程2
    线程、进程与协程
    if __name=='__main__"的作用
    动态导入模块
    面向对象补充之方法
    getpass模块
  • 原文地址:https://www.cnblogs.com/hwlong/p/6063292.html
Copyright © 2020-2023  润新知