獲取url引數
在 ngx_lua 中訪問 Nginx 內建變數 ngx.var.arg_PARAMETER 即可獲得GET引數PARAMETER的內容。
在 nginx配置中,透過$arg_PARAMETER 即可獲得GET引數PARAMETER的內容。
獲取請求頭
在 ngx_lua 中訪問 Nginx 內建變數 ngx.var.http_HEADER 即可獲得請求頭HEADER的內容。
在 nginx配置中,透過$http_HEADER 即可獲得請求頭HEADER的內容。
透過以下方式進行驗證,比如說,透過 http://www.test.com?name=hello&id=123 來驗證url的請求引數,能夠在nginx中獲取到,只需要修改nginx.conf 配置檔案如下,就可以在access.log中看到id和name在log中
http {
include mime.types;
default_type application/octet-stream;
log_format main "{ "@timestamp": "$time_iso8601", "
""servername": "$http_host", "
""id": "$arg_id","
""name": "$arg_name","
""remote_addr": "$remote_addr","
""referer": "$http_referer","
""request": "$request","
""request_time": "$request_time","
""status": $status,"
""bytes":$body_bytes_sent,"
""agent": "$http_user_agent","
""x_forwarded": "$http_x_forwarded_for","
""upstr_addr": "$upstream_addr","
""upstr_host": "$upstream_http_host","
""ups_resp_time": "$upstream_response_time" }";
access_log logs/access.log main;
server_names_hash_bucket_size 128;
獲取url引數
在 ngx_lua 中訪問 Nginx 內建變數 ngx.var.arg_PARAMETER 即可獲得GET引數PARAMETER的內容。
在 nginx配置中,透過$arg_PARAMETER 即可獲得GET引數PARAMETER的內容。
獲取請求頭
在 ngx_lua 中訪問 Nginx 內建變數 ngx.var.http_HEADER 即可獲得請求頭HEADER的內容。
在 nginx配置中,透過$http_HEADER 即可獲得請求頭HEADER的內容。
透過以下方式進行驗證,比如說,透過 http://www.test.com?name=hello&id=123 來驗證url的請求引數,能夠在nginx中獲取到,只需要修改nginx.conf 配置檔案如下,就可以在access.log中看到id和name在log中
http {
include mime.types;
default_type application/octet-stream;
log_format main "{ "@timestamp": "$time_iso8601", "
""servername": "$http_host", "
""id": "$arg_id","
""name": "$arg_name","
""remote_addr": "$remote_addr","
""referer": "$http_referer","
""request": "$request","
""request_time": "$request_time","
""status": $status,"
""bytes":$body_bytes_sent,"
""agent": "$http_user_agent","
""x_forwarded": "$http_x_forwarded_for","
""upstr_addr": "$upstream_addr","
""upstr_host": "$upstream_http_host","
""ups_resp_time": "$upstream_response_time" }";
access_log logs/access.log main;
server_names_hash_bucket_size 128;