2

Openresty 常用的 ngx 包和方法

 1 year ago
source link: https://www.jansora.com/notebook/107605
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

openresty 都有哪些 ngx 包或方法

OpenResty 是一个基于 Nginx 和 LuaJIT 的 Web 平台,提供了大量的模块和库以便开发高性能的 Web 应用。以下是一些常见的 OpenResty 与 Nginx 相关的 ngx 模块和方法:

  1. ngx_http_lua_module: 这是一个核心模块,允许在 Nginx 配置文件中嵌入 Lua 代码和调用 Lua 脚本。它提供了诸如 ngx.say, ngx.print, ngx.exec, ngx.redirect 等方法。

  2. ngx_http_rewrite_module: 提供 URL 重写功能,例如使用 ngx.re.write 和 ngx.re.gmatch 等方法进行正则表达式匹配和替换。

  3. ngx_http_proxy_module: 提供反向代理功能,允许将请求转发到其他服务器。这个模块包含了 ngx.location.capture, ngx.location.capture_multi 等方法。

  4. ngx_http_upstream_module: 用于管理上游服务器,并根据负载均衡算法将请求分发到不同的服务器。常用的方法有 ngx.balancer.set_current_peer 和 ngx.balancer.get_last_failure 等。

  5. ngx_http_ssl_module: 提供 SSL/TLS 支持,包括 ngx.ssl.handshake 和 ngx.ssl.get_tls1_version 等方法。

  6. ngx_http_realip_module: 允许修改客户端 IP 地址,例如使用 ngx.var.remote_addr 和 ngx.var.realip_remote_addr 等方法。

  7. ngx_http_limit_req_module: 提供请求速率限制功能,例如使用 ngx.shared.DICT:incr 方法实现计数器功能。

  8. ngx_http_auth_request_module: 提供基于子请求的访问控制,例如使用 ngx.location.capture 和 ngx.req.set_header 等方法实现认证功能。

  9. ngx_http_gzip_module: 提供对 HTTP 响应进行 gzip 压缩的功能。

  10. ngx_http_log_module: 提供日志记录功能,例如使用 ngx.log 和 ngx.ERR 等方法记录错误信息。

  11. ngx_http_headers_module: 允许修改 HTTP 响应头,例如使用 ngx.header.content_type 和 ngx.header.set 等方法。

这仅仅是 OpenResty 和 Nginx 提供的众多 ngx 模块和方法中的一部分。你可以在 OpenResty 和 Nginx 的官方文档中找到更多详细信息和示例。

以上使用方法在哪个地方能找到 api 文档呢

以下是 OpenResty 和 Nginx 相关模块和方法的 API 文档链接:

  1. OpenResty 官方文档:https://openresty.org/en/documentation.html OpenResty 的官方文档提供了详细的模块和方法说明,以及一些示例和教程。

  2. ngx_lua (ngx_http_lua_module) 文档:https://github.com/openresty/lua-nginx-module#readme 这是 ngx_lua 模块的官方文档,包含了大量的模块和方法说明。

  3. Nginx 官方文档:http://nginx.org/en/docs/ Nginx 官方文档包含了所有内置模块的详细说明,以及配置指令和示例。

在上述文档中,你可以找到 OpenResty 和 Nginx 提供的各种 ngx 模块和方法的详细 API 文档。通常情况下,你可以在 OpenResty 文档中找到大部分与 Lua 相关的方法,而在 Nginx 文档中找到标准的 Nginx 模块和配置指令。同时,针对一些特定的模块,你可以参考它们各自的 GitHub 仓库和文档。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK