亚洲乱色熟女一区二区三区丝袜,天堂√中文最新版在线,亚洲精品乱码久久久久久蜜桃图片,香蕉久久久久久av成人,欧美丰满熟妇bbb久久久

LOGO OA教程 ERP教程 模切知識交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

nginx http模塊的一些常用內(nèi)置變量

admin
2025年6月28日 22:15 本文熱度 124

服務(wù)器相關(guān)

  • $server_addr:服務(wù)器地址
  • $server_name:虛擬主機(jī)名(server_name指令的配置)
  • $server_port:服務(wù)器端口
  • $document_root:root或alias命令配置的路徑,可能是軟鏈接。
  • $realpath_root:當(dāng)前請求對應(yīng)到的真實(shí)路徑,絕對路徑。
  • $request_filename:當(dāng)前請求的文件路徑,基于root或alias的配置組合出的路徑
  • $host:如果請求頭中有Host就為該值,否則為server_name(nginx配置中的server)
  • $hostname:nginx所在主機(jī)名
  • $nginx_version:nginx版本
  • $pid:worker進(jìn)程ID
  • $limit_rate:limit_rate指令的設(shè)置值。

變量用途舉例,記錄日志:

http {
 log_format about_server_log 'server_addr:$server_addr,server_name:$server_name,server_port:$server_port\n'
        'document_root:$document_root,realpath_root:$realpath_root,request_filename:$request_filename\n'
        'host:$host,hostname:$hostname,nginx_version:$nginx_version\n'
        'pid:$pid,limit_rate:$limit_rate';
 server {
  listen 80;
  server_name localhost;
  access_log logs/server.log about_server_log;

        location / {
            root   /var/www/html;
            index  index.html index.htm;
        }

  location /api/ {
   proxy_pass http://localhost:8009/api/;
   limit_rate 100k;
  }
 }
}

請求http://xxx.xxx.xxx.xxx/5.jpg時(shí),$document_root值為root指令配置的路徑,為軟鏈接,$realpath_root的值為真實(shí)物理路徑。請求http://xxx.xxx.xxx.xxx/api/student/11時(shí)由代理服務(wù)響應(yīng),$request_filename值是基于root的配置與$uri組合得出的: 


客戶端相關(guān)

  • $binary_remote_addr:客戶端IP的二進(jìn)制
  • $remote_addr:客戶端IP
  • $remote_port:客戶端端口
  • $remote_user:Http Basic認(rèn)證時(shí)的用戶名
  • $request:http請求,包括方法,uri,協(xié)議及版本
  • $request_method:請求方法
  • $request_uri:完整URI
  • $request_completion:請求完成時(shí)值為OK,否則空字符串
  • $args或$query_string:請求參數(shù)
  • $arg_name:請求參數(shù)中的name值
  • $is_args:如果有請求參數(shù)值為?否則為空字符串
  • $scheme:請求協(xié)議,http或https
  • $https:連接協(xié)議如果為https值為on,否則為空字符串
  • $http_host:請求頭中的Host值
  • $http_name:請求頭中的name值
  • $content_length:請求頭中的Content-Length
  • $content_type:請求頭中的Content-Type
  • $cookie_name:取cookie中key為name的值,name也只可以是其它名稱
  • $document_uri:就是$uri
  • $server_protocol:http協(xié)議版本

用于if判斷舉例:

server {
 listen 80;
 server_name localhost;

 location /api/ {
  # 傳遞Http Basic認(rèn)證的用戶名給上游服務(wù)
  proxy_set_header X-User $remote_user;


 # 判斷請求方法
 if ($request_method != "GET") {
   return 405 "method not allowed";
  }


# 檢查能處理的Content-Type類型
 if ($content_type != "application/json") {
   return 415 "Unsupported Media Type";
  } 
  proxy_pass http://localhost:8009/api/;
 } 
}


server {
 listen 81;
 server_name localhost;

 location / {
  # 將http請求重定向到https:
  if ($scheme = "http") {
   return 301 https://$host:443$request_uri;
  }

  ...
 } 
}

響應(yīng)相關(guān)

  • $status:響應(yīng)狀態(tài)碼
  • $sent_http_name:響應(yīng)頭中name值
  • $body_bytes_sent:響應(yīng)體字節(jié)數(shù)
  • $bytes_sent:響應(yīng)字節(jié)數(shù)

代理相關(guān)

  • $upstream_addr:上游服務(wù)器的IP和端口
  • $upstream_status:上游服務(wù)器的響應(yīng)狀態(tài)碼
  • $upstream_response_time:上游服務(wù)的響應(yīng)時(shí)長
  • $proxy_host:proxy_pass指令中目標(biāo)服務(wù)器的主機(jī)名和端口
  • $proxy_port:proxy_pass指令中目標(biāo)服務(wù)器的端口


閱讀原文:原文鏈接


該文章在 2025/7/1 23:50:06 編輯過
關(guān)鍵字查詢
相關(guān)文章
正在查詢...
點(diǎn)晴ERP是一款針對中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場、車隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場作業(yè)而開發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉儲(chǔ)管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購管理,倉儲(chǔ)管理,倉庫管理,保質(zhì)期管理,貨位管理,庫位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時(shí)間、不限用戶的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved