nginx學習(五) http模組

2021-07-06 03:39:07 字數 1584 閱讀 4108

一、http核心模組

1、alias

語法: alias file-path|directory-path;

預設值: no

作用域: location

該指令設定指定location使用的路徑.注意它跟 root 相似,但是不改變檔案的根路徑,僅僅是使用檔案系統路徑

比如:location  /i/

請求 "/i/top.gif" 將返回檔案 "/spool/w3/images/top.gif".

在替換路徑中可以使用變數.

alias 無法在正則的 location中使用. 如果你需要這麼做,你必須結合使用指令rewrite 和 root.

2、root

追加路徑

root與alias區別:alias是將請求替換為alias的值。root是將請求追加到root後。看下面兩個例子:

root

location ~ ^/awstats/

二、http log模組

1、access_log

語法: access_log path [format [buffer=size | off ] 預設值: access_log log/access.log combined

作用域: http, server, location

指令 access_log 指派路徑、格式和快取大小。

2、log_format

語法: log_format name format [format ...]

name為格式名稱,可以在其他地方引用該格式。

log_format formatname 'format'

access_log /user/access.log formatname

預設值: log_format combined "..."

作用域: http server

示例:

log_format  gzip  '$remote_addr - $remote_user [$time_local]  '

access_log /spool/logs/nginx-access.log gzip buffer=32k;

上例中gzip為name,『』中的內容為format

nginx配置詳解之http模組

http模組控制著nginx http處理的所有核心特性 以下為常用配置 注 keepalive timeout open file cache也可以配置在http模組 與配置在event模組相同 詳見 log format日誌配置 負載均衡 反向 等配置此處省略介紹 我將在介紹相應的模組時詳細介紹...

HTTP學習筆記(五)

目前,市場上流行有很多web 伺服器軟體,每種伺服器都有自己的特點。我們在開發的過程中,經常要和它們打交道,所以了解它們的工作原理也是很重要的。幾款比較流行的伺服器 第三篇中有這樣的一張,它演示了客戶端和伺服器在發起事務時它們需要做的幾個事情。這裡就詳細地談談伺服器在執行過程中會做什麼。首先伺服器在...

Nginx服務 五 核心配置模組

注意以下閱讀時 syntax 語法 default 預設值 example 示例default type 在響應報文中將指定的副檔名對映至mime對應的型別 syntax default type mime type default default type text plain context h...