第十二周-day52(上)-负载均衡的设备转换、动静分离与高可用介绍_负载均衡 切换 设备

最后的话

最近很多小伙伴找我要Linux学习资料,于是我翻箱倒柜,整理了一些优质资源,涵盖视频、电子书、PPT等共享给大家!

资料预览

给大家整理的视频资料:

给大家整理的电子书资料:

如果本文对你有帮助,欢迎点赞、收藏、转发给朋友,让我有持续创作的动力!

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以点击这里获取!

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!


二、根据用户客户端的设备 进行转发 请求:

1.配置 upstream 与location

定义upstream移动端与PC端

 upstream  default {
     server 10.0.0.7:80 weight=1 max_fails=3 fail_timeout=10s;
     }
     upstream mobile {
     server 10.0.0.8:80 weight=1 max_fails=3 fail_timeout=10s;
     }

移动端的服务器池

     location / {
        if ($http_user_agent ~\* "Android|IOS") {
        proxy_pass http://mobile;
        }

完整配置

[root@lb01 nginx]# vim nginx.conf 
...
     upstream  default {
     server 10.0.0.7:80 weight=1 max_fails=3 fail_timeout=10s;
     }
     upstream mobile {
     server 10.0.0.8:80 weight=1 max_fails=3 fail_timeout=10s;
     }
# include /etc/nginx/conf.d/\*.conf;
     server {
     listen 80;
     server_name www.oldboy.com;
     location / {
        if ($http\_user\_agent ~* "Android|IOS") {
        proxy_pass http://mobile;
        }
         proxy_pass http://default;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $remote\_addr;
        }
     }
[root@lb01 nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@lb01 nginx]# systemctl reload nginx

记得将之前环境中的其他模块一起修改或暂时注释掉,不然语法会报错

2.curl一下查看结果

curl -A 可以指定系统

[root@lb01 nginx]# curl 10.0.0.5/lidao.html
this is PC website
[root@lb01 nginx]# curl -A ios 10.0.0.5/lidao.html
this is Mobile website
[root@lb01 nginx]# curl -A Android 10.0.0.5/lidao.html
this is Mobile website

3.可以下载火狐浏览器查看

http://www.firefox.com.cn/
安装插件流程:

三、根据 URI 中的目录地址实现代理转发(动静分离)

添加一台测试web03节点—10.0.0.9
将web03的配置与web01和web02配置相同
(/app站点目录与nginx.conf配置文件)


1.准备环境
www.oldboy.com/upload/index.html
www.oldboy.com/static/index.html
www.oldboy.com/index.html

#web01:
mkdir -p /app/www/upload/index.html
echo this is upload >/app/www/index.html
[root@web01 ~]# cat /app/www/upload/index.html 
this is upload

#web02:
mkdir -p /app/www/static/index.html
echo this is static >/app/www/index.html
[root@web02 ~]# cat /app/www/static/index.html 
this is static

#web03:
mkdir -p /app/www/index.html  #之前已经有首页文件,只需修改内容
echo this is default >/app/www/index.html
[root@web03 ~]# cat /app/www/index.html 
this is default

2.配置 upstream 与location

定义upstream.

     upstream  upload {
     server 10.0.0.7:80 weight=1 max_fails=3 fail_timeout=10s;
     }
     upstream static {
     server 10.0.0.8:80 weight=1 max_fails=3 fail_timeout=10s;
     }
     upstream default {
     server 10.0.0.9:80 weight=1 max_fails=3 fail_timeout=10s;
     }

添加location

     server {
     listen 80;
     server_name www.oldboy.com;
     location /upload {
         proxy_pass http://upload;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $remote\_addr;
        }
     location /static {
         proxy_pass http://static;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $remote\_addr;
        }
     location /default {
         proxy_pass http://default;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $remote\_addr;
        }
     }

完整配置

[root@lb01 nginx]# vim nginx.conf 
....
     upstream  upload {
     server 10.0.0.7:80 weight=1 max_fails=3 fail_timeout=10s;
     }


![](https://img-blog.csdnimg.cn/img_convert/9a8cb5f8c0ec69e6499adead0da6e95b.png)


最全的Linux教程,Linux从入门到精通

======================

1.  **linux从入门到精通(第2版)**

2.  **Linux系统移植**

3.  **Linux驱动开发入门与实战**

4.  **LINUX 系统移植 第2版**

5.  **Linux开源网络全栈详解 从DPDK到OpenFlow**



![华为18级工程师呕心沥血撰写3000页Linux学习笔记教程](https://img-blog.csdnimg.cn/img_convert/59742364bb1338737fe2d315a9e2ec54.png)



第一份《Linux从入门到精通》466页

====================

内容简介

====

本书是获得了很多读者好评的Linux经典畅销书**《Linux从入门到精通》的第2版**。本书第1版出版后曾经多次印刷,并被51CTO读书频道评为“最受读者喜爱的原创IT技术图书奖”。本书第﹖版以最新的Ubuntu 12.04为版本,循序渐进地向读者介绍了Linux 的基础应用、系统管理、网络应用、娱乐和办公、程序开发、服务器配置、系统安全等。本书附带1张光盘,内容为本书配套多媒体教学视频。另外,本书还为读者提供了大量的Linux学习资料和Ubuntu安装镜像文件,供读者免费下载。



![华为18级工程师呕心沥血撰写3000页Linux学习笔记教程](https://img-blog.csdnimg.cn/img_convert/9d4aefb6a92edea27b825e59aa1f2c54.png)



**本书适合广大Linux初中级用户、开源软件爱好者和大专院校的学生阅读,同时也非常适合准备从事Linux平台开发的各类人员。**

> 需要《Linux入门到精通》、《linux系统移植》、《Linux驱动开发入门实战》、《Linux开源网络全栈》电子书籍及教程的工程师朋友们劳烦您转发+评论




**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化的资料的朋友,可以点击这里获取!](https://bbs.csdn.net/topics/618542503)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

发的各类人员。**

> 需要《Linux入门到精通》、《linux系统移植》、《Linux驱动开发入门实战》、《Linux开源网络全栈》电子书籍及教程的工程师朋友们劳烦您转发+评论




**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化的资料的朋友,可以点击这里获取!](https://bbs.csdn.net/topics/618542503)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值