您的位置:首页 > 汽车 > 时评 > 全球国家综合实力排名_网站建设相关技术_广州企业网站推广_国产搜什么关键词最好看

全球国家综合实力排名_网站建设相关技术_广州企业网站推广_国产搜什么关键词最好看

2024/9/19 21:45:42 来源:https://blog.csdn.net/qq_43527128/article/details/142365167  浏览:    关键词:全球国家综合实力排名_网站建设相关技术_广州企业网站推广_国产搜什么关键词最好看
全球国家综合实力排名_网站建设相关技术_广州企业网站推广_国产搜什么关键词最好看

一、拓扑结构

							 [vip: 20.20.20.20]
外网 桥接模式(vip)
内网 nat模式[LB1 Nginx]		    [LB2 Nginx]192.168.1.2		192.168.1.3[index]		[milis]		 [videos]	   [images]  	  [news]1.11		 1.21		   1.31			1.41		  1.511.12		 1.22		   1.32			1.42		  1.521.13		 1.23		   1.33			1.43		  1.53...		 ...		   ...			...		      .../web     /web/milis    /web/videos     /web/images   /web/newsindex.html  index.html     index.html      index.html   index.html

分析:
1.准备三台虚拟机
2.每台机器安装nginx

yum -y install nginx

代理机:需要添加一个桥接模式的网卡 ,保证同一网段内其他真实机器可以访问
因为是实验环境 直接VMware上添加即可

9: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:d1:c4:a1 brd ff:ff:ff:ff:ff:ffinet 192.168.101.89/24 brd 192.168.101.255 scope global noprefixroute dynamic ens36valid_lft 53818sec preferred_lft 53818sec

还剩两台服务器这里模仿有五个业务场景 每个业务场景有两台负载机 即一共需要十个机器,这里用新增ip的方式来模拟 剩余两台每台机器新增五个ip

ip addr add 192.168.1.100/24 dev eth0 #添加
ip addr del 192.168.1.100/24 dev eth0 #删除# 需要注意的是这里的网段需要一样才能访问????  这里有疑问  暂时未解决ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:fb:ff:6f brd ff:ff:ff:ff:ff:ffinet 192.168.29.143/24 brd 192.168.29.255 scope global noprefixroute ens33valid_lft forever preferred_lft foreverinet 192.168.29.160/24 scope global secondary ens33valid_lft forever preferred_lft foreverinet 192.168.29.161/24 scope global secondary ens33valid_lft forever preferred_lft foreverinet 192.168.29.162/24 scope global secondary ens33valid_lft forever preferred_lft foreverinet 192.168.29.163/24 scope global secondary ens33valid_lft forever preferred_lft foreverinet 192.168.29.164/24 scope global secondary ens33valid_lft forever preferred_lft forever
# 这里每个ip 代表一个业务机[index][milis][videos][images][news]

代理机上配置添加:

    upstream index {server 192.168.29.170:80 weight=1 max_fails=2 fail_timeout=2;server 192.168.29.160:80 weight=2 max_fails=2 fail_timeout=2;}upstream news {server 192.168.29.171:81 weight=1 max_fails=2 fail_timeout=2;server 192.168.29.161:81 weight=2 max_fails=2 fail_timeout=2;}upstream milis {server 192.168.29.172:80 weight=1 max_fails=2 fail_timeout=2;server 192.168.29.162:80 weight=2 max_fails=2 fail_timeout=2;}upstream videos {server 192.168.29.173:80 weight=1 max_fails=2 fail_timeout=2;server 192.168.29.163:80 weight=2 max_fails=2 fail_timeout=2;}upstream images {server 192.168.29.174:80 weight=1 max_fails=2 fail_timeout=2;server 192.168.29.164:80 weight=2 max_fails=2 fail_timeout=2;}server {location / {proxy_pass http://index/;}location  /news {proxy_pass http://news/;}location /milis {proxy_pass http://milis/;}location ~* \.(wmv|mp4|rmvb)$ { proxy_pass http://videos; }location ~* \.(png|gif|jpg)$ { proxy_pass http://images;}}# 这里需要注意的点是proxy_pass http://videos;proxy_pass http://milis/;
# 结尾/的问题
# 加/ 的情况假设你的访问路径  curl xxxxx/aa/milis   proxy_pass http://milis/;  结尾加了/   这里会将location后面匹配到的部分去掉  你的url就变为了  http://milis组负载均衡到的的ip/aa 
# 不加/ 的情况 会保留 即 假设你的 curl  xxxx/a.png     通过正则匹配location ~* \.(png|gif|jpg)$     实际url 就是:http://images组负载均衡到的的ip/a.png

服务器
下面以images 举例 首先在conf.d/下新增images.conf这个配置文件

server {listen       192.168.29.164:80;server_name  www.images.com;root         /usr/share/nginx/html/images;access_log   /var/log/nginx/index-access.log  main;# Load configuration files for the default server block.# include /etc/nginx/default.d/*.conf;location /  {index index.html  index.hml;}error_page 404 /404.html;location = /404.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {}
} [root@slave01 html]# tree /etc/nginx/
/etc/nginx/
├── conf.d
│   ├── default.conf
│   ├── images.conf
│   ├── index.conf
│   ├── milis.conf
│   ├── news.conf
│   └── videos.conf
├── fastcgi_params
├── mime.types
├── modules -> ../../usr/lib64/nginx/modules
├── nginx.conf
├── scgi_params
└── uwsgi_params

然后根据root /usr/share/nginx/html/images 新增发布文件目录

[root@slave01 html]# tree /usr/share/nginx/
/usr/share/nginx/
└── html├── 50x.html├── images│   ├── a.png│   └── index.html├── index│   └── index.html├── index.html├── milis│   └── index.html├── news│   └── index.html└── videos├── a.mp4└── index.html

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com