openeuler與centos差異,openresty 內置變量

 2023-12-25 阅读 75 评论 0

摘要:openresty 內置變量 ?????????? 官網:http://nginx.org/en/docs/varindex.html ???????? ????????????? ????????????????????????????????? 常用內置變量 openeuler與centos差異,?????????? openresty 獲取nginx的內置變量 nginx 內置變量:$arg_name openres

openresty 內置變量

??????????

官網:http://nginx.org/en/docs/varindex.html

????????

?????????????

?????????????????????????????????

常用內置變量

openeuler與centos差異,??????????

openresty 獲取nginx的內置變量

nginx 內置變量:$arg_name
openresty lua_ngx獲取方式:ngx.var.arg_name

?????????????

請求、響應變量

$request:記錄請求的URL、http
$request_uri:請求的url,帶參數
$request_time:請求到達nginx,一直到返回響應花費的時間
$request_method:請求方法,如:get、post等
$request_length:請求的長度,包括請求頭、請求體
$request_filename:請求的文件路徑,基于root alias指令、url生成$uri:當前請求的uri
$document_uri:uri別名$arg_name:url中的名為name的參數
$args:獲取所有參數$cookie_name:cookie名為name的值
$sent_http_name:任意響應頭$binary_remote_addr:客戶端地址(二進制形式)
$body_bytes_sent:發送給客戶端的字節數,不包含響應頭
$bytes_sent:發送給客戶端的總字節數(響應頭、響應體)$scheme:協議,如:http、https等
$hostname:主機名(nginx所在服務器的主機名)
$status:http請求狀態$http_referer:請求是從哪個頁面鏈接過來的
$http_user_agent:客戶端瀏覽器信息

?????????

ip、port等變量

# 客戶端信息
$remote_addr:客戶端ip
$remote_port:客戶端端口
$remote_user:客戶端用戶名$realip_remote_addr:保留原來的客戶端地址# 服務端信息
$server_name:服務器名稱(通常是域名)
$server_addr:服務器地址
$server_port:服務器端口號
$server_protocol:請求協議、版本號,如:http1.0、http1.1# 反向代理信息
$upstream_addr:請求反向代理后,傳到后端的ip
$upstream_port:請求反向代理后,傳到后端的端口
$upstream_status:反向代理請求在nginx的http狀態
$upstream_response_time:反向代理請求在nginx消耗的時間

openjdk環境變量配置。??????????????

其他變量

$pid:woker進程號
$nginx_version:nginx版本號
$connection_requests:連接的請求量$geoip_city:城市名稱
$time_local:通用日志格式下的本地時間
$msec:日志寫入時間,單位為秒,精度為毫秒$pipe:如果請求是http流水線發送的,值為"p",否則為"."

?????????

???????????????

?????????????????????????????????

使用示例

??????????

jenkins內置變量、nginx.conf

events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;server {location /lua {         default_type "applictaion/json";content_by_lua "ngx.say('hello gtlx')";}location /hello {         content_by_lua_block {ngx.say(ngx.var.uri);     # 輸出uringx.say(ngx.var.args);    # 輸出路徑參數ngx.say(ngx.var.scheme);  # 輸出scheme}}}client_body_temp_path /var/run/openresty/nginx-client-body;proxy_temp_path       /var/run/openresty/nginx-proxy;fastcgi_temp_path     /var/run/openresty/nginx-fastcgi;uwsgi_temp_path       /var/run/openresty/nginx-uwsgi;scgi_temp_path        /var/run/openresty/nginx-scgi;sendfile        on;keepalive_timeout  65;}

???????

創建容器

docker run -it -d -p 8082:80 \
-v /Users/huli/lua/openresty/conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf \
--name openresty3 lihu12344/openresty

????????

使用測試

huli@hudeMacBook-Pro openresty % curl localhost:8082/lua
hello gtlxhuli@hudeMacBook-Pro openresty % curl localhost:8082/hello
/hello
nil
http

??????????

jmeter內置變量、??????????????????

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://808629.com/196785.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 86后生记录生活 Inc. 保留所有权利。

底部版权信息