You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: meta/3rd/OpenResty/library/ngx.lua
+272-5Lines changed: 272 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1924,9 +1924,216 @@ function DICT:free_space() end
1924
1924
---
1925
1925
--- This API requires a relatively expensive metamethod call and it is recommended to avoid using it on hot code paths.
1926
1926
---
1927
+
---@typetable
1928
+
ngx.var= {}
1929
+
1930
+
--- Embedded Variables
1931
+
--- see https://nginx.org/en/docs/http/ngx_http_core_module.html#variables
1932
+
1933
+
--- client address in a binary form, value’s length is always 4 bytes for IPv4 addresses or 16 bytes for IPv6 addresses
1934
+
---@typestring
1935
+
ngx.var.binary_remote_addr=nil
1936
+
1937
+
--- number of bytes sent to a client, not counting the response header; this variable is compatible with the “%B” parameter of the mod_log_config Apache module
1938
+
---@typenumber
1939
+
ngx.var.body_bytes_sent=nil
1940
+
1941
+
--- number of bytes sent to a client (1.3.8, 1.2.5)
1942
+
---@typenumber
1943
+
ngx.var.bytes_sent=nil
1944
+
1945
+
--- connection serial number (1.3.8, 1.2.5)
1946
+
---@typestring
1947
+
ngx.var.connection=nil
1948
+
1949
+
--- current number of requests made through a connection (1.3.8, 1.2.5)
1950
+
---@typestring
1951
+
ngx.var.connection_requests=nil
1952
+
1953
+
--- connection time in seconds with a milliseconds resolution (1.19.10)
1954
+
---@typestring
1955
+
ngx.var.connection_time=nil
1956
+
1957
+
--- “Content-Length” request header field
1958
+
---@typestring
1959
+
ngx.var.content_length=nil
1960
+
1961
+
--- “Content-Type” request header field
1962
+
---@typestring
1963
+
ngx.var.content_type=nil
1964
+
1965
+
--- root or alias directive’s value for the current request
1966
+
---@typestring
1967
+
ngx.var.document_root=nil
1968
+
1969
+
--- same as ngx.var.uri
1970
+
---@typestring
1971
+
ngx.var.document_uri=nil
1972
+
1973
+
--- in this order of precedence: host name from the request line, or host name from the “Host” request header field, or the server name matching a request
1974
+
---@typestring
1975
+
ngx.var.host=nil
1976
+
1977
+
--- host name
1978
+
---@typestring
1979
+
ngx.var.hostname=nil
1980
+
1981
+
--- “on” if connection operates in SSL mode, or an empty string otherwise
1982
+
---@typestring '"on"'|'""'
1983
+
ngx.var.https=nil
1984
+
1985
+
--- “?” if a request line has arguments, or an empty string otherwise
1986
+
---@typestring
1987
+
ngx.var.is_args=nil
1988
+
1989
+
--- setting this variable enables response rate limiting; see limit_rate
1990
+
---@typestring
1991
+
ngx.var.limit_rate=nil
1992
+
1993
+
--- current time in seconds with the milliseconds resolution (1.3.9, 1.2.6)
1994
+
---@typestring
1995
+
ngx.var.msec=nil
1996
+
1997
+
--- nginx version
1998
+
---@typestring
1999
+
ngx.var.nginx_version=nil
2000
+
2001
+
--- PID of the worker process
2002
+
---@typestring
2003
+
ngx.var.pid=nil
2004
+
2005
+
--- “p” if request was pipelined, “.” otherwise (1.3.12, 1.2.7)
2006
+
---@typestring
2007
+
ngx.var.pipe=nil
2008
+
2009
+
--- client address from the PROXY protocol header (1.5.12)
2010
+
--- The PROXY protocol must be previously enabled by setting the proxy_protocol parameter in the listen directive.
2011
+
---@typestring
2012
+
ngx.var.proxy_protocol_addr=nil
2013
+
2014
+
--- client port from the PROXY protocol header (1.11.0)
2015
+
---
2016
+
--- The PROXY protocol must be previously enabled by setting the proxy_protocol parameter in the listen directive.
2017
+
---@typestring
2018
+
ngx.var.proxy_protocol_port=nil
2019
+
2020
+
--- server address from the PROXY protocol header (1.17.6)
2021
+
---
2022
+
--- The PROXY protocol must be previously enabled by setting the proxy_protocol parameter in the listen directive.
2023
+
---@typestring
2024
+
ngx.var.proxy_protocol_server_addr=nil
2025
+
2026
+
--- server port from the PROXY protocol header (1.17.6)
2027
+
---
2028
+
--- The PROXY protocol must be previously enabled by setting the proxy_protocol parameter in the listen directive.
2029
+
---@typestring
2030
+
ngx.var.proxy_protocol_server_port=nil
2031
+
2032
+
--- same as ngx.var.args
2033
+
---@typestring
2034
+
ngx.var.query_string=nil
2035
+
2036
+
--- an absolute pathname corresponding to the root or alias directive’s value for the current request, with all symbolic links resolved to real paths
2037
+
---@typestring
2038
+
ngx.var.realpath_root=nil
2039
+
2040
+
--- client address
2041
+
---@typestring
2042
+
ngx.var.remote_addr=nil
2043
+
2044
+
--- client port
2045
+
---@typestring
2046
+
ngx.var.remote_port=nil
2047
+
2048
+
--- user name supplied with the Basic authentication
2049
+
---@typestring
2050
+
ngx.var.remote_user=nil
2051
+
2052
+
--- full original request line
2053
+
---@typestring
2054
+
ngx.var.request=nil
2055
+
2056
+
--- request body
1927
2057
---
1928
-
---@classngx.var:table<string,any>
2058
+
--- The variable’s value is made available in locations processed by the proxy_pass, fastcgi_pass, uwsgi_pass, and scgi_pass directives when the request body was read to a memory buffer.
2059
+
---@typestring
2060
+
ngx.var.request_body=nil
2061
+
2062
+
--- name of a temporary file with the request body
1929
2063
---
2064
+
--- At the end of processing, the file needs to be removed.
2065
+
--- To always write the request body to a file, client_body_in_file_only needs to be enabled.
2066
+
--- When the name of a temporary file is passed in a proxied request or in a request to a FastCGI/uwsgi/SCGI server, passing the request body should be disabled by the proxy_pass_request_body off, fastcgi_pass_request_body off, uwsgi_pass_request_body off, or scgi_pass_request_body off directives, respectively.
2067
+
---@typestring
2068
+
ngx.var.request_body_file=nil
2069
+
2070
+
--- “OK” if a request has completed, or an empty string otherwise
2071
+
---@typestring
2072
+
ngx.var.request_completion=nil
2073
+
2074
+
--- file path for the current request, based on the root or alias directives, and the request URI
2075
+
---@typestring
2076
+
ngx.var.request_filename=nil
2077
+
2078
+
--- unique request identifier generated from 16 random bytes, in hexadecimal (1.11.0)
--- request processing time in seconds with a milliseconds resolution (1.3.9, 1.2.6); time elapsed since the first bytes were read from the client
2091
+
---@typestring
2092
+
ngx.var.request_time=nil
2093
+
2094
+
--- full original request URI (with arguments)
2095
+
---@typestring
2096
+
ngx.var.request_uri=nil
2097
+
2098
+
--- request scheme, “http” or “https”
2099
+
---@typestring
2100
+
ngx.var.scheme=nil
2101
+
2102
+
--- an address of the server which accepted a request
2103
+
---
2104
+
--- Computing a value of this variable usually requires one system call. To avoid a system call, the listen directives must specify addresses and use the bind parameter.
2105
+
---@typestring
2106
+
ngx.var.server_addr=nil
2107
+
2108
+
--- name of the server which accepted a request
2109
+
---@typestring
2110
+
ngx.var.server_name=nil
2111
+
2112
+
--- port of the server which accepted a request
2113
+
---@typestring
2114
+
ngx.var.server_port=nil
2115
+
2116
+
--- request protocol, usually “HTTP/1.0”, “HTTP/1.1”, or “HTTP/2.0”
2117
+
---@typestring
2118
+
ngx.var.server_protocol=nil
2119
+
2120
+
--- response status (1.3.2, 1.2.2)
2121
+
---@typestring
2122
+
ngx.var.status=nil
2123
+
2124
+
--- local time in the ISO 8601 standard format (1.3.12, 1.2.7)
2125
+
---@typestring
2126
+
ngx.var.time_iso8601=nil
2127
+
2128
+
--- local time in the Common Log Format (1.3.12, 1.2.7)
2129
+
---@typestring
2130
+
ngx.var.time_local=nil
2131
+
2132
+
--- current URI in request, normalized
2133
+
--- The value of $uri may change during request processing, e.g. when doing internal redirects, or when using index files.
2134
+
---@typestring
2135
+
ngx.var.uri=nil
2136
+
1930
2137
--- Updating query arguments via the Nginx variable `$args` (or `ngx.var.args` in Lua) at runtime is also supported:
1931
2138
---
1932
2139
--- ```lua
@@ -1943,10 +2150,70 @@ function DICT:free_space() end
1943
2150
--- ```
1944
2151
---
1945
2152
--- regardless of the actual request query string.
--- IP address and port, or the path to the UNIX-domain socket of the upstream server.
2160
+
--- If several servers were contacted during request processing, their addresses are separated by commas, e.g. “192.168.1.1:80, 192.168.1.2:80, unix:/tmp/sock”.
2161
+
--- If an internal redirect from one server group to another happens, initiated by “X-Accel-Redirect” or error_page, then the server addresses from different groups are separated by colons, e.g. “192.168.1.1:80, 192.168.1.2:80, unix:/tmp/sock : 192.168.10.1:80, 192.168.10.2:80”.
2162
+
--- If a server cannot be selected, the variable keeps the name of the server group.
2163
+
---@typestring
2164
+
ngx.var.upstream_addr=nil
2165
+
2166
+
--- number of bytes received from an upstream server (1.11.4). Values from several connections are separated by commas and colons like addresses in the $upstream_addr variable.
2167
+
---@typestring
2168
+
ngx.var.upstream_bytes_received=nil
2169
+
2170
+
--- number of bytes sent to an upstream server (1.15.8). Values from several connections are separated by commas and colons like addresses in the $upstream_addr variable.
2171
+
---@typestring
2172
+
ngx.var.upstream_bytes_sent=nil
2173
+
2174
+
--- status of accessing a response cache (0.8.3). The status can be either “MISS”, “BYPASS”, “EXPIRED”, “STALE”, “UPDATING”, “REVALIDATED”, or “HIT”.
2175
+
---@typestring
2176
+
ngx.var.upstream_cache_status=nil
2177
+
2178
+
--- time spent on establishing a connection with the upstream server (1.9.1)
2179
+
--
2180
+
--- the time is kept in seconds with millisecond resolution.
2181
+
--- In case of SSL, includes time spent on handshake.
2182
+
--- Times of several connections are separated by commas and colons like addresses in the $upstream_addr variable.
2183
+
---@typestring
2184
+
ngx.var.upstream_connect_time=nil
2185
+
2186
+
--- time spent on receiving the response header from the upstream server (1.7.10)
2187
+
--- the time is kept in seconds with millisecond resolution.
2188
+
--- Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
2189
+
---@typestring
2190
+
ngx.var.upstream_header_time=nil
2191
+
2192
+
--- the time the request spent in the upstream queue (1.13.9).
2193
+
--- the time is kept in seconds with millisecond resolution.
2194
+
--- Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
2195
+
---@typestring
2196
+
ngx.var.upstream_queue_time=nil
2197
+
2198
+
--- the length of the response obtained from the upstream server (0.7.27).
2199
+
--- the length is kept in bytes.
2200
+
--- Lengths of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
2201
+
---@typestring
2202
+
ngx.var.upstream_response_length=nil
2203
+
2204
+
--- time spent on receiving the response from the upstream server
2205
+
---
2206
+
--- the time is kept in seconds with millisecond resolution.
2207
+
--- Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
2208
+
---@typestring
2209
+
ngx.var.upstream_response_time=nil
2210
+
2211
+
--- status code of the response obtained from the upstream server.
2212
+
--- Status codes of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
2213
+
--- If a server cannot be selected, the variable keeps the 502 (Bad Gateway) status code.
0 commit comments