Nginx官方模塊
第三方模塊
模塊一 stub_status
--with-http_stub_status_module Nginx的客戶端狀態(tài),連接信息
配置語法
Syntax: stub_status;
Default: -
Context:server,location
修改 nginx.conf 中的 default.conf
應(yīng)該在 /etc/nginx/site-enable/default.conf
vim default.conf
在server中 加上一個location
location /mystatus {
stub_status;
}
這樣就可以在訪問時 輸入指定域名 就可以查詢到了一些連接信息
模塊二 random_index
--with-http_random_index_module 目錄中選擇一個隨機主頁
隨機主頁 增加用戶新鮮感 很少用
配置語法
Syntax: random_index on|off;
Default: random_index off;
Context:location
location / {
root /opt/app/code;; #放首頁的目錄
random_index on; #隨機打開
}
nginx -tc 檢查語法是否正確
ps -aux|grep nginx 查看進程狀態(tài)
模塊三 sub_module
--with-http_sub_module http內(nèi)容替換
配置語法
Syntax: sub_filter string replacement;
Default: -
Context:http,server,location
string 代表 要替換的內(nèi)容 #舊
replacement 要替換后的內(nèi)容 #新
作用 頭信息,服務(wù)端給客服端,校驗頭信息是否發(fā)生過變更,以時間的格式,判斷是否有更新,有更新就發(fā)送更新的內(nèi)容。
主要用于緩存
Syntax: sub_filter_last_modified on | off;
Default:sub_filter_last_modified off; #默認(rèn)關(guān)閉
Context:http,server,location
作用 我是匹配html代碼的第一個 ,還是所有字符串。
on 匹配第一個 ,off全匹配
Syntax: sub_filter_once on | off;
Default:sub_filter_once on; #默認(rèn)開啟
Context:http,server,location
使用sub_filter
location / {
root /opt/app/code;; #放首頁的目錄
#random_index on; #隨機打開
index index.html index.htm;
sub_filter '<a>someone' '<a>SOMEONE';
sub_filter_once off;
}