日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Nginx >内容正文

Nginx

Nginx调度器(反向代理),TCP/UDP调度器

發布時間:2025/4/16 Nginx 165 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nginx调度器(反向代理),TCP/UDP调度器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一,nginx反向代理

環境

步驟一: 部署后端Web 服務器web1和web2:以web1為例:

yum -y install gcc pcre-devel openssl-devel yum -y install gcc pcre-devel openssl-devel tar -xf nginx-1.10.3.tar.gz cd nginx-1.10.3 useradd -s /sbin/nologin nginx ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module make make install mv nginx-1.1* /usr/local/nginx/ ln -s /usr/local/nginx/sbin/nginx /sbin/ nginx netstat -antulp |grep nginx echo "192.168.1.100" > /usr/local/nginx/html/index.html

二,安裝nginx,修改配置,添加服務器池,實現反向代理功能

1,安裝Nginx

yum -y install gcc pcre-devel openssl-devel cd nginx-1.10.3 useradd -s /sbin/nologin nginx ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module make & make install ln -s /usr/local/nginx/sbin/nginx /sbin/ nginx netstat -antulp | grep nginx

2,修改Nginx配置文件

vim /usr/local/nginx/conf/nginx.conf35 #使用upstream定義后端服務器集群,集群名稱隨意(如webserver)36 #使用server定義集群中服務器的IP和端口37 upstream webserver {38 server 192.168.1.100:80;39 server 192.168.1.200:80;40 }41 ... ...52 location / {53 proxy_pass http://webserver;54 #通過proxy_pass將用戶的請求轉發給webserver集群nginx -s reload

?

三,客戶端訪問測試

http://192.168.0.2/? ? ?訪問測試刷新出現不同的頁面,配置成功!!

配置upstream服務器集群池屬性

vim /usr/local/nginx/conf/nginx.conf37 upstream webserver {38 server 192.168.1.100 weight=1 max_fails=1 fail_timeout=30;39 server 192.168.1.200 weight=2 max_fails=2 fail_timeout=30;40 server 192.168.1.101 down;41 } 42 #weight設置服務器權重值,默認值為143 #max_fails設置最大失敗次數44 #fail_timeout設置失敗超時時間,單位為秒45 #down標記服務器已關機,不參與集群調度

?

配置upstream服務器集群的調度算法

vim /usr/local/nginx/conf/nginx.conf37 upstream webserver {38 ip_hash;39 #通過ip_hash設置調度規則為:相同客戶端訪問相同服務器40 server 192.168.1.100 weight=1 max_fails=1 fail_timeout=30;41 server 192.168.1.200 weight=2 max_fails=2 fail_timeout=30;42 server 192.168.1.101 down;43 }

?

# nginx -s reload

客戶端使用瀏覽器訪問代理服務器測試輪詢效果
# curl http://192.168.0.2? ? ? ? ???//使用該命令多次訪問查看效果

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

?

二 ,TCP/UDP調度器

?

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

?

?

?

?

?

?

總結

以上是生活随笔為你收集整理的Nginx调度器(反向代理),TCP/UDP调度器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。