初學Nginx(三)upstream初步體驗

2021-08-07 11:10:50 字數 700 閱讀 8921

新建四個springboot工程

都新增org.springframework.boot

spring-boot-starter-web

1.5.4.release

工程1  名稱為8021  埠為8021

@restcontroller

public class main8021

public string index()

}工程2  名稱為8022  埠為8022、跟1一樣、只是埠和名字改了

@restcontroller

public class main8023

public string index()

}工程4  名稱為8024  埠為8024、跟3一樣、只是埠和名字改了

#處a之外的**給b

location /}}

訪問http://localhost/a/會分別負載到http://localhost:8021/a和http://localhost:8022/a上

訪問http://localhost/會分別負載到http://localhost:8023/和http://localhost:8024/上

Nginx基礎應用 集群搭建upstream

輪詢 upstream預設分配方式 upstream xiecongcong加權輪詢 即可以指定輪詢比率,weight和訪問機率成正比。weight 1 預設 值越大,權重越大。upstream xiecongcongip hash 每個請求按照訪問ip的hash結果分配,這樣每個訪客會固定訪問乙個...

nginx初學入門配置

主要有master程序和worker程序,使用命令檢視 master在只有乙個 worker預設情況下只有乙個,可以通過配置增加worker程序 相當於領導者 相當於工作者,為master服務 修改worker程序數量,首先進入nignx的配置檔案 vim nginx.conf圖中數字1代表乙個wo...

Nginx初學(三)日誌的配置

1 進入到nginx的日誌目錄,我們可以看到下圖的三個檔案 其中nginx.pid中存放的是程序號,access.log是訪問日誌,error是錯誤日誌。2 我們開啟配置檔案,可以設定自己的日誌檔案。如下,配置好後儲存,重啟nginx。server access log logs wuaipic.l...