Nginx配置詳解

2021-09-24 03:30:53 字數 1837 閱讀 5390

nginx是一款自由的、開源的、高效能的http伺服器和反向**伺服器;同時也是乙個imap、pop3、smtp**伺服器;nginx可以作為乙個http伺服器進行**的發布處理,另外nginx可以作為反向**進行負載均衡的實現。

nginx工作流程圖:

日誌access.log具體每項代表的意思:

$remote_addr   客戶端位址   211.28.65.253

$remote_user 客戶端使用者名稱 --

$time_local 訪問時間和時區 18/jul/2012:17:00:01 +0800

$request 請求的uri和http協議 "get /article-10000.html http/1.1"

$http_host 請求位址,即瀏覽器中你輸入的位址(ip或網域名稱) www.it300.com

192.168.100.100

$status http請求狀態 200

$upstream_status upstream狀態 200

$body_bytes_sent 傳送給客戶端檔案內容大小 1547

$http_referer url跳轉**

$http_user_agent 使用者終端瀏覽器等資訊 "mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0; sv1; gtb7.0; .net4.0c;

$ssl_protocol ssl協議版本 tlsv1

$ssl_cipher 交換資料中的演算法 rc4-sha

$upstream_addr 後台upstream的位址,即真正提供服務的主機位址 10.10.10.100:80

$request_time 整個請求的總時間 0.205

$upstream_response_time 請求過程中,upstream響應時間 0.002

自己定義log的格式

配置http模組負載均衡

upstream bakend

server

}

在stream模組中配置反向**

stream

server

}

location規則配置:

Nginx配置詳解

nginx的主要配置檔案是nginx.conf,位於安裝目錄下的nginx conf資料夾裡,主要的配置引數如下 定義nginx執行的使用者和使用者組 user nobody nobody nginx程序數,建議設定為等於cpu總核心數。worker processes 8 全域性錯誤日誌定義型別,...

nginx配置詳解

定義nginx執行的使用者和使用者組 user www www nginx程序數,建議設定為等於cpu總核心數。worker processes 8 全域性錯誤日誌定義型別,debug info notice warn error crit error log var log nginx error...

NGINX配置詳解

nginx 配置檔案 user nginx 使用者worker processes 8 工作程序,根據硬體調整,大於等於cpu核數 error log logs nginx error.log crit 錯誤日誌 pid logs nginx.pid pid放置的位置 worker rlimit n...