国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB服務 > 正文

關于Nginx常用的官方模塊

2020-03-22 18:00:09
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了 關于Nginx常用的官方模塊,有著一定的參考價值,現在分享給大家,有需要的朋友可以參考一下
Nginx常用官方模塊
Nginx采用模塊化的架構,Nginx中大部分功能都是通過模塊方式提供的,比如HTTP模塊、Mail模塊等。

Nginx官方模塊文檔

1. ngx_http_stub_status_module編譯選項
--with-http_stub_status_module
作用

提供Nginx當前處理連接等基本狀態信息的訪問

語法
Syntax: stub_status;Default: —Context: server, location
用法

在nginx配置文件中的 server 下配置

server { # 添加的配置 location /nginx_status { stub_status; ...其它代碼省略...}

修改后重新載入配置文件nginx -s reload

瀏覽器中訪問 http:// ip /nginx_status,會返回如下內容

Active connections: 3 server accepts handled requests 7 7 16 Reading: 0 Writing: 1 Waiting: 2
Active connections: Nginx當前活躍鏈接數
accepts: 接收客戶端連接的總次數
handled: 處理客戶端連接的總次數。一般來說,這個參數值與accepts相同,除非已經達到了一些資源限制(例如worker_connections限制)
requests: 客戶端請求的總次數
Reading: 當前nginx正在讀取請求頭的連接數
Writing: 當前nginx正在寫入響應的連接數
Reading: 當前正在等待請求的空閑客戶端連接數。一般是在nginx開啟長連接(keep alive)情況下出現。2. ngx_http_random_index_module編譯選項
--with-http_random_index_module
作用

在主目錄中選擇一個隨機文件作為主頁

語法
Syntax: random_index on | off;Default: random_index off;Context: location
用法

在nginx配置文件中的 server 下配置

server { location / { root /usr/share/nginx/html; #添加這一行開啟隨機主頁模塊 random_index on; #把指定的主頁注釋掉 #index index.html index.htm; ...其它代碼省略...}
3. ngx_http_sub_module編譯選項
--with-ngx_http_sub_module
作用

通過替換一個指定的字符串來修改響應

語法

指定被替換的字符和替代字符

Syntax: sub_filter string replacement;Default: —Context: http, server, location

Last-Modified,用于校驗服務端內容是否更改,主要用于緩存場景

Syntax: sub_filter_last_modified on | off;Default: sub_filter_last_modified off;Context: http, server, location

默認只替換找到的第一個字符串,若替換文本中的所有匹配的字符串,則置為off

Syntax: sub_filter_once on | off;Default: sub_filter_once on;Context: http, server, location

除了“text/html”之外,還可以用指定的MIME類型替換字符串。特殊值‘*’匹配任意MIME類型

Syntax: sub_filter_types mime-type ...;Default: sub_filter_types text/html;Context: http, server, location
用法

在nginx配置文件中的 server 下配置

server { location / { root /usr/share/nginx/html; index index.html; # 將首頁的nginx替換為home sub_filter nginx home  # 不止替換第一個,而是替換response中所有的nginx sub_filter_once off; ...其它代碼省略...}

修改后重新載入配置文件nginx -s reload

curl localhost,返回如下內容,會發現響應中所有nginx已經替換為home

[vagrant/etc/nginx]$ curl localhost !DOCTYPE html  html  head  title Welcome to home! /title  style  body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; /style  /head  body  h1 Welcome to home! /h1  p If you see this page, the home web server is successfully installed andworking. Further configuration is required. /p  p For online documentation and support please refer to a href= http://home.org/ home.org /a . br/ Commercial support is available at a href= http://home.com/ home.com /a . /p  p em Thank you for using home. /em /p  /body  /html 

以上就是本文的全部內容,希望對大家的學習有所幫助,更多相關內容請關注PHP !

相關推薦:

關于php-fpm的進程數管理

為 Nginx 添加模塊的方法

快速搭建Nginx及其基本參數的配置

以上就是關于Nginx常用的官方模塊的詳細內容,PHP教程

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 长岛县| 武宁县| 嵊州市| 饶阳县| 正阳县| 韶山市| 昌邑市| 临西县| 无棣县| 花莲市| 闵行区| 鄯善县| 神池县| 桐庐县| 邯郸县| 阿荣旗| 新绛县| 松潘县| 略阳县| 若羌县| 五指山市| 田阳县| 鞍山市| 清涧县| 东阿县| 陇南市| 山东省| 兰溪市| 邵东县| 英德市| 沾益县| 革吉县| 城步| 瓮安县| 略阳县| 高要市| 双城市| 衡阳市| 岳阳县| 信阳市| 扎鲁特旗|