运维技术分享平台

 找回密码
 立即注册
首页
查看: 284|回复: 0

nginx根据用户请求不同终端均衡

[复制链接]

296

主题

305

帖子

1701

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1701
发表于 2023-3-27 10:15:56 | 显示全部楼层 |阅读模式
  [root@lb01 conf.d]# cat lb.conf
    upstream web {
       server 10.0.0.8:80;
    }
    upstream mobile {
       server 10.0.0.7:80;
    }
    upstream default {
       server 10.0.0.9:80;
    }

    server {
        listen       80;
        server_name  www.it.com;
        location / {
           if ($http_user_agent ~* iphone) {
              proxy_pass http://mobile;
           }
           if ($http_user_agent ~* Chrome) {
             proxy_pass  http://web;
           }
           proxy_pass http://default;
           proxy_set_header Host $host;
           proxy_set_header X-Forwarded-For $remote_addr;
           proxy_next_upstream error timeout http_404 http_502 http_403;
        }
    }

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

首页

手机版|关于自己|运维技术分享平台

GMT+8, 2024-4-20 15:42 , Processed in 0.082890 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc. Template By 【未来科技】【 www.wekei.cn 】

快速回复 返回顶部 返回列表