openresty HTTP status constants nginx api for lua

https://github.com/openresty/lua-nginx-module

context: init_by_lua, set_by_lua, rewrite_by_lua, access_by_lua, content_by_lua, header_filter_by_lua, body_filter_by_lua, log_by_lua, ngx.timer., balancer_by_lua, ssl_certificate_by_lua, ssl_session_fetch_by_lua, ssl_session_store_by_lua*

   value = ngx.HTTP_CONTINUE (100) (first added in the v0.9.20 release)
   value = ngx.HTTP_SWITCHING_PROTOCOLS (101) (first added in the v0.9.20 release)
   value = ngx.HTTP_OK (200)
   value = ngx.HTTP_CREATED (201)
   value = ngx.HTTP_ACCEPTED (202) (first added in the v0.9.20 release)
   value = ngx.HTTP_NO_CONTENT (204) (first added in the v0.9.20 release)
   value = ngx.HTTP_PARTIAL_CONTENT (206) (first added in the v0.9.20 release)
   value = ngx.HTTP_SPECIAL_RESPONSE (300)
   value = ngx.HTTP_MOVED_PERMANENTLY (301)
   value = ngx.HTTP_MOVED_TEMPORARILY (302)
   value = ngx.HTTP_SEE_OTHER (303)
   value = ngx.HTTP_NOT_MODIFIED (304)
   value = ngx.HTTP_TEMPORARY_REDIRECT (307) (first added in the v0.9.20 release)
   value = ngx.HTTP_PERMANENT_REDIRECT (308)
   value = ngx.HTTP_BAD_REQUEST (400)
   value = ngx.HTTP_UNAUTHORIZED (401)
   value = ngx.HTTP_PAYMENT_REQUIRED (402) (first added in the v0.9.20 release)
   value = ngx.HTTP_FORBIDDEN (403)
   value = ngx.HTTP_NOT_FOUND (404)
   value = ngx.HTTP_NOT_ALLOWED (405)
   value = ngx.HTTP_NOT_ACCEPTABLE (406) (first added in the v0.9.20 release)
   value = ngx.HTTP_REQUEST_TIMEOUT (408) (first added in the v0.9.20 release)
   value = ngx.HTTP_CONFLICT (409) (first added in the v0.9.20 release)
   value = ngx.HTTP_GONE (410)
   value = ngx.HTTP_UPGRADE_REQUIRED (426) (first added in the v0.9.20 release)
   value = ngx.HTTP_TOO_MANY_REQUESTS (429) (first added in the v0.9.20 release)
   value = ngx.HTTP_CLOSE (444) (first added in the v0.9.20 release)
   value = ngx.HTTP_ILLEGAL (451) (first added in the v0.9.20 release)
   value = ngx.HTTP_INTERNAL_SERVER_ERROR (500)
   value = ngx.HTTP_METHOD_NOT_IMPLEMENTED (501)
   value = ngx.HTTP_BAD_GATEWAY (502) (first added in the v0.9.20 release)
   value = ngx.HTTP_SERVICE_UNAVAILABLE (503)
   value = ngx.HTTP_GATEWAY_TIMEOUT (504) (first added in the v0.3.1rc38 release)
   value = ngx.HTTP_VERSION_NOT_SUPPORTED (505) (first added in the v0.9.20 release)
   value = ngx.HTTP_INSUFFICIENT_STORAGE (507) (first added in the v0.9.20 release)

Nginx log level constants

context: init_by_lua, init_worker_by_lua, set_by_lua, rewrite_by_lua, access_by_lua, content_by_lua, header_filter_by_lua, body_filter_by_lua, log_by_lua, ngx.timer., balancer_by_lua, ssl_certificate_by_lua, ssl_session_fetch_by_lua, ssl_session_store_by_lua

   ngx.STDERR
   ngx.EMERG
   ngx.ALERT
   ngx.CRIT
   ngx.ERR
   ngx.WARN
   ngx.NOTICE
   ngx.INFO
   ngx.DEBUG

print(...) 等于 ngx.log(ngx.NOTICE, ...)

nginx 内置绑定变量 ngx.var.xxx

名称 说明

$arg_name    请求中的name参数
$args   请求中的参数
$binary_remote_addr     远程地址的二进制表示
$body_bytes_sent        已发送的消息体字节数
$content_length HTTP请求信息里的"Content-Length"
$content_type   请求信息里的"Content-Type"
$document_root  针对当前请求的根路径设置值
$document_uri   与$uri相同; 比如 /test2/test.php
$host   请求信息中的"Host",如果请求中没有Host行,则等于设置的服务器名
$hostname       机器名使用 gethostname系统调用的值
$http_cookie    cookie 信息
$http_referer   引用地址
$http_user_agent        客户端代理信息
$http_via       最后一个访问服务器的Ip地址。
$http_x_forwarded_for   相当于网络访问路径
$is_args        如果请求行带有参数,返回“?”,否则返回空字符串
$limit_rate     对连接速率的限制
$nginx_version  当前运行的nginx版本号
$pid    worker进程的PID
$query_string   与$args相同
$realpath_root  按root指令或alias指令算出的当前请求的绝对路径。其中的符号链接都会解析成真是文件路径
$remote_addr    客户端IP地址
$remote_port    客户端端口号
$remote_user    客户端用户名,认证用
$request        用户请求
$request_body   这个变量(0.7.58+)包含请求的主要信息。在使用proxy_pass或fastcgi_pass指令的location中比较有意义
$request_body_file      客户端请求主体信息的临时文件名
$request_completion     如果请求成功,设为"OK";如果请求未完成或者不是一系列请求中最后一部分则设为空
$request_filename       当前请求的文件路径名,比如/opt/nginx/www/test.php
$request_method 请求的方法,比如"GET"、"POST"等
$request_uri    请求的URI,带参数
$scheme 所用的协议,比如http或者是https
$server_addr    服务器地址,如果没有用listen指明服务器地址,使用这个变量将发起一次系统调用以取得地址(造成资源浪费)
$server_name    请求到达的服务器名
$server_port    请求到达的服务器端口号
$server_protocol        请求的协议版本,"HTTP/1.0"或"HTTP/1.1"
$uri    请求的URI,可能和最初的值有不同,比如经过重定向之类的

https://github.com/openresty/lua-nginx-module#nginx-api-for-lua

Nginx API for Lua
Introduction
ngx.arg
ngx.var.VARIABLE
Core constants
HTTP method constants
HTTP status constants
Nginx log level constants
print
ngx.ctx
ngx.location.capture
ngx.location.capture_multi
ngx.status
ngx.header.HEADER
ngx.resp.get_headers
ngx.req.is_internal
ngx.req.start_time
ngx.req.http_version
ngx.req.raw_header
ngx.req.get_method
ngx.req.set_method
ngx.req.set_uri
ngx.req.set_uri_args
ngx.req.get_uri_args
ngx.req.get_post_args
ngx.req.get_headers
ngx.req.set_header
ngx.req.clear_header
ngx.req.read_body
ngx.req.discard_body
ngx.req.get_body_data
ngx.req.get_body_file
ngx.req.set_body_data
ngx.req.set_body_file
ngx.req.init_body
ngx.req.append_body
ngx.req.finish_body
ngx.req.socket
ngx.exec
ngx.redirect
ngx.send_headers
ngx.headers_sent
ngx.print
ngx.say
ngx.log
ngx.flush
ngx.exit
ngx.eof
ngx.sleep
ngx.escape_uri
ngx.unescape_uri
ngx.encode_args
ngx.decode_args
ngx.encode_base64
ngx.decode_base64
ngx.crc32_short
ngx.crc32_long
ngx.hmac_sha1
ngx.md5
ngx.md5_bin
ngx.sha1_bin
ngx.quote_sql_str
ngx.today
ngx.time
ngx.now
ngx.update_time
ngx.localtime
ngx.utctime
ngx.cookie_time
ngx.http_time
ngx.parse_http_time
ngx.is_subrequest
ngx.re.match
ngx.re.find
ngx.re.gmatch
ngx.re.sub
ngx.re.gsub
ngx.shared.DICT
ngx.shared.DICT.get
ngx.shared.DICT.get_stale
ngx.shared.DICT.set
ngx.shared.DICT.safe_set
ngx.shared.DICT.add
ngx.shared.DICT.safe_add
ngx.shared.DICT.replace
ngx.shared.DICT.delete
ngx.shared.DICT.incr
ngx.shared.DICT.lpush
ngx.shared.DICT.rpush
ngx.shared.DICT.lpop
ngx.shared.DICT.rpop
ngx.shared.DICT.llen
ngx.shared.DICT.ttl
ngx.shared.DICT.expire
ngx.shared.DICT.flush_all
ngx.shared.DICT.flush_expired
ngx.shared.DICT.get_keys
ngx.shared.DICT.capacity
ngx.shared.DICT.free_space
ngx.socket.udp
udpsock:setpeername
udpsock:send
udpsock:receive
udpsock:close
udpsock:settimeout
ngx.socket.stream
ngx.socket.tcp
tcpsock:connect
tcpsock:sslhandshake
tcpsock:send
tcpsock:receive
tcpsock:receiveany
tcpsock:receiveuntil
tcpsock:close
tcpsock:settimeout
tcpsock:settimeouts
tcpsock:setoption
tcpsock:setkeepalive
tcpsock:getreusedtimes
ngx.socket.connect
ngx.get_phase
ngx.thread.spawn
ngx.thread.wait
ngx.thread.kill
ngx.on_abort
ngx.timer.at
ngx.timer.every
ngx.timer.running_count
ngx.timer.pending_count
ngx.config.subsystem
ngx.config.debug
ngx.config.prefix
ngx.config.nginx_version
ngx.config.nginx_configure
ngx.config.ngx_lua_version
ngx.worker.exiting
ngx.worker.pid
ngx.worker.count
ngx.worker.id
ngx.semaphore
ngx.balancer
ngx.ssl
ngx.ocsp
ndk.set_var.DIRECTIVE
coroutine.create
coroutine.resume
coroutine.yield
coroutine.wrap
coroutine.running
coroutine.status