------------------location匹配规则:
location = / {
# 只匹配"/".
[ configuration A ]
}
location / {
# 匹配任何请求,因为所有请求都是以"/"开始
# 但是更长字符匹配或者正则表达式匹配会优先匹配
[ configuration B ]
}
location ^~ /images/ {
# 匹配任何以 /images/ 开始的请求,并停止匹配 其它location
[ configuration C ]
}
location ~* \.(gif|jpg|jpeg)$ {
# 匹配以 gif, jpg, or jpeg结尾的请求,忽略大小写。
# 但是所有 /images/ 目录的请求将由 [Configuration C]处理。
[ configuration D ]
}
---------------------一些可用的全局变量:
ngx.var.
$args
$content_length
$content_type
$document_root
$document_uri
$host
$http_user_agent
$http_cookie ngx.var.http_cookie
$limit_rate
$request_body_file
$request_method
$remote_addr
$remote_port
$remote_user
$request_filename
$request_uri
$query_string
$scheme
$server_protocol
$server_addr
$server_name
$server_port
$uri
nginx lua api:
ngx.thread.spawn
ngx.thread.wait
ngx.thread.kill
ngx.location.capture
ngx.location.capture_multi
ngx.timer.at
ngx.worker.pid
ngx.worker.count
ngx.worker.id
ngx.status
ngx.req.start_time
ngx.req.get_method
ngx.req.get_headers()["Host"]
ngx.req.set_header("Content-Type", "text/css")
ngx.req.clear_header
ngx.req.get_body_data
ngx.exec
ngx.redirect
ngx.say
ngx.log
ngx.quote_sql_str
ngx.re.gsub
ngx.shared.DICT
详细介绍请看:
https://github.com/iresty/nginx-lua-module-zh-wiki
ngx_lua 模块提供的指令和API等:
http://www.cnblogs.com/wangxusummer/p/4309007.html