大旗谷资源网 Design By www.zqyou.com
详解Linux系统配置nginx的负载均衡
负载均衡的几种方式:
1.轮询:默认按照时间顺序对所有服务器一个一个的访问,如果有服务器宕机,会自动剔除;
2.weight:服务器的方位几率和weight成正比,这个可以在服务器配置不均的时候进行配置;
3.ip_hash:对每个请求的ip进行hash计算,并按照一定的规则分配对应的服务器(可解决session共享);
4.fair:按照每台服务器的响应时间(rt)来分配请求,rt知道优先分配;
5.url_hash:按照访问url的hash值来分配请求;
NGINX配置文件:
user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include blockip.conf; #过虑IP include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; upstream www.域名.com { server IP1:端口; #服务器1 server IP2:端口; #服务器2 ip_hash; #负载均衡的规则 } server { listen 80 default_server; #NGINX 指向的服务域名 listen [::]:80 default_server; server_name IP; #NGINX 指向的服务器 IP root /usr/share/nginx/html; #NGINX HTML 目录 # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_pass http://www.域名.com; #nginx指向的域名 } error_page 404 /404.html; location = /40x.html { #404页面 } error_page 500 502 503 504 /500.html; location = /500.html { #500页面 } } }
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
大旗谷资源网 Design By www.zqyou.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
大旗谷资源网 Design By www.zqyou.com
暂无详解Linux系统配置nginx的负载均衡的评论...
更新日志
2024年09月20日
2024年09月20日
- [ABC]安娜-胆麦发烧女声[6N纯银镀膜][2016[低速原抓WAV+CUE]
- 任天堂今晚举行直面会!第三方及独立游戏展示
- 《哆啦A梦的铜锣烧店物语》发售!开罗公式+哆啦A梦
- 任天堂公布《塞尔达传说》系列时间线:野炊与王泪独立在外
- 五条人.2012-一些风景2CD【刀马旦】【WAV+CUE】
- 陈奕迅.2013-Easons.Life演唱会2CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 许美静.1995-遗憾(新马版)【上华】【WAV+CUE】
- 《叶倩文 歌声情缘》[WAV+CUE][410MB]
- 《张国荣 首首动听经典不容错过 追忆的风 2CD》[WAV+CUE][870MB]
- 《腾格尔 容中尔甲 亚东 高原三星 男人篇 3CD》[WAV/分轨][1GB]
- 命运圣契公测实测可用兑换码大全 命运圣契最新兑换码分享
- 黑神话悟空上品疾蝠精魄获取方法一览|上品疾蝠精魄收集攻略
- 《七龙珠电光炸裂!ZERO》GT角色预告片曝光,15位新角色登场
- [ABC]安娜-胆麦发烧女声[6N纯银镀膜][2016[低速原抓WAV+CUE]
- NewViennaOctetViennaWindSoloists-TheDeccaRecordings(2024)18CD[24-48][FLAC]-7