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

歡迎訪問 生活随笔!

生活随笔

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

Nginx

Nginx模块之SessionSticky

發布時間:2024/9/20 Nginx 61 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nginx模块之SessionSticky 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

0?工作原理

?

Session Sticky?模塊在upstream?返回響應后,向客戶的瀏覽器寫入?Cookie?,默認名為route?,保存的內容是一個?md5?碼。

之后,模塊接收到客戶瀏覽器的請求時,就根據?route?來決定將請求轉發到?upstream中哪臺服務器上。

?

這是源碼包中附帶的流程圖,將模塊的處理流程描述的非常清晰:

?


1?下載?Session Sticky

wget https://nginx-sticky-module.googlecode.com/files/nginx-sticky-module-1.1.tar.gz

?


2?安裝模塊

如果?Nginx?之前已經安裝了,可以通過?nginx -V?命令查看當時編譯的參數。在參數后面追加安裝?Session Sticky?模塊的參數,

避免影響之前?Nginx?已有模塊。

進入?nginx?源碼目錄,執行命令:

./configure …? --add-module=/usr/local/src/nginx-sticky-module-1.1

?????????make

?????????make install

?


3?激活模塊

在?upstream塊中添加?sticky;?即可激活Session Sticky模塊。

?

upstream {

??sticky;

? server 127.0.0.1:9000;

? server 127.0.0.1:9001;

? server 127.0.0.1:9002;

}

?


4?可用選項

The "sticky" command can take several arguments to control its behaviour:

? sticky [name=route] [domain=.foo.bar] [path=/] [expires=1h] [hash=index|md5|sha1] [no_fallback];

?

Configuration

Description

Parameters

Default Value

name

the name of the cookie used to track the persistant upstream srv

can be any string

"route"

domain

the domain in which the cookie will be valid

can be any string

nothing. Let the browser handle this.

path

the path in which the cookie will? ?? ?be valid

can be any path

nothing. Let the browser handle this.

expires

the validity duration of the cookie

must be a duration greater than one second

nothing. It's a session cookie

hash

the hash mechanism to encode upstream server. It cant' be used? ?? ?with hmac

md5|sha1

md5

hmac

The HMAC hash mechanism to encode upstream server. It's like? ?? ?the hash mechanism but it uses hmac_key to secure the hashing.? ?? ?It can't be used with hash.

md5|sha1

none

hmac_key

The key to use with hmac. It's mandatory when hmac is set.

can be any string

none

no_fallback

When this flag is set, nginx will return a 502 (Bad Gateway orProxy Error) if a request comes? ?? ?with a cookie and the corresponding backend is unavailable.

no arguments

none

來源:https://blog.csdn.net/dc_726/article/details/12348907

總結

以上是生活随笔為你收集整理的Nginx模块之SessionSticky的全部內容,希望文章能夠幫你解決所遇到的問題。

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