以下对比基于 nginx/1.20.1和openresty/1.21.4.3,因为版本差异实际会有出入,仅供参考

Nginx 模块功能详解

默认禁用的模块(需要使用–with-选项启用)

模块 功能描述
select_module 提供基于select()的事件处理机制,在不支持更高效的事件处理机制的平台上使用
poll_module 提供基于poll()的事件处理机制,是select的替代方案
threads 启用线程池支持,可以将特定操作(如磁盘IO)放到单独的线程中处理
file-aio 启用异步I/O文件操作支持,提高文件读写性能
http_ssl_module 提供HTTPS支持,实现SSL/TLS加密通信
http_v2_module 支持HTTP/2协议
http_realip_module 修改客户端请求头中的客户端IP地址值
http_addition_module 在响应前后添加文本内容
http_xslt_module 使用XSLT转换XML响应
http_image_filter_module 处理图片(调整大小、旋转、水印等)
http_geoip_module 根据客户端IP地址确定地理位置
http_sub_module 修改响应,用一个指定字符串替换另一个
http_dav_module 提供WebDAV协议支持
http_flv_module 为Flash Video (FLV)文件提供伪流媒体服务器支持
http_mp4_module 为MP4文件提供伪流媒体服务器支持
http_gunzip_module 为不支持"gzip"编码方法的客户端解压响应
http_gzip_static_module 提供静态压缩支持,发送预压缩的.gz文件
http_auth_request_module 基于子请求结果实现客户端授权
http_random_index_module 从目录中随机选择一个文件作为索引文件
http_secure_link_module 检查请求链接的真实性、保护资源免受未授权访问、限制链接有效期
http_degradation_module 内存不足时允许返回特定错误码
http_slice_module 将请求拆分为子请求,每个子请求返回响应的特定切片
http_stub_status_module 提供对基本状态信息的访问

默认启用的模块(可以使用–without-选项禁用)

模块 功能描述
http_charset_module 添加指定的字符集到"Content-Type"响应头字段,可转换数据
http_gzip_module 动态压缩HTTP响应,减少传输数据量
http_ssi_module 处理服务器端包含(SSI)命令
http_userid_module 设置适合客户端识别的cookie
http_access_module 限制对特定客户端地址的访问
http_auth_basic_module 通过HTTP基本认证协议验证用户名和密码
http_mirror_module 将请求镜像到指定位置,用于流量复制和测试
http_autoindex_module 处理以斜杠字符(‘/’)结尾的请求并生成目录列表
http_geo_module 创建依赖于客户端IP地址的变量
http_map_module 创建基于其他变量值的变量
http_split_clients_module 创建A/B测试的变量
http_referer_module 根据"Referer"请求头字段的值阻止对站点的访问
http_rewrite_module 使用正则表达式改变请求URI并返回重定向,条件性地选择配置
http_proxy_module 将请求传递到另一台服务器
http_fastcgi_module 将请求传递到FastCGI服务器
http_uwsgi_module 将请求传递到uwsgi服务器
http_scgi_module 将请求传递到SCGI服务器
http_grpc_module 将请求传递到gRPC服务器
http_memcached_module 从memcached服务器获取响应
http_limit_conn_module 限制并发连接数或下载速率
http_limit_req_module 限制每个用户的请求处理速率
http_empty_gif_module 在内存中常驻一个1x1像素的透明GIF,减少磁盘访问
http_browser_module 创建依赖于"User-Agent"请求头值的变量
http_upstream_hash_module 实现基于哈希的负载均衡方法
http_upstream_ip_hash_module 实现基于客户端IP的负载均衡方法
http_upstream_least_conn_module 实现选择具有最少活动连接的服务器的负载均衡方法
http_upstream_random_module 实现随机选择服务器的负载均衡方法
http_upstream_keepalive_module 为上游服务器保持缓存连接
http_upstream_zone_module 为共享内存区域中的负载均衡配置提供支持

OpenResty 模块功能详解

OpenResty 是基于 Nginx 的高性能 Web 平台,集成了 LuaJIT,提供了许多额外的模块。以下是 OpenResty 中的模块功能详解。

OpenResty 特有的默认启用模块(可以使用 --without- 选项禁用)

模块 功能描述
http_echo_module 提供简单的 echo/sleep/time/exec 等指令,用于输出内容、延迟、获取时间和执行命令
http_xss_module 用于跨站脚本过滤,可以通过正则表达式过滤请求参数
http_coolkit_module 提供一系列小工具集合,如请求/响应时间计算、变量设置等
http_set_misc_module 提供各种设置 Nginx 变量的工具,如正则替换、JSON 编码/解码等
http_form_input_module 解析 POST 请求的表单数据,支持 application/x-www-form-urlencoded 和 multipart/form-data
http_encrypted_session_module 提供加密会话数据的功能
http_srcache_module 提供透明的服务器端缓存,支持从 Redis、Memcached 等后端存储中获取/存储响应
http_lua_module 核心模块,将 Lua 嵌入到 Nginx 中,允许使用 Lua 脚本编写高级应用
http_lua_upstream_module 通过 Lua API 操作 Nginx 的上游(upstream)模块
http_headers_more_module 允许更改、添加或清除请求/响应头信息
http_array_var_module 支持数组型变量
http_memc_module 扩展的 Memcached 客户端,支持直接访问 Memcached 服务器
http_redis2_module Redis 2.0 协议客户端,用于直接访问 Redis 服务器
http_redis_module Redis 客户端,支持 Redis 的 GET/SET 等操作
http_rds_json_module 将 Resty DBD 流(RDS)转换为 JSON 格式
http_rds_csv_module 将 Resty DBD 流(RDS)转换为 CSV 格式
stream_lua_module 在 Nginx 的 Stream 模块中使用 Lua 脚本
ngx_devel_kit_module Nginx 开发工具包,为其他模块提供扩展功能
stream TCP/UDP 代理模块
http_ssl_module 提供 HTTPS 支持
stream_ssl_module 为 TCP/UDP 代理提供 SSL/TLS 加密支持

OpenResty 特有的默认禁用模块(需要使用 --with- 选项启用)

模块 功能描述
http_iconv_module 提供字符集转换功能
http_drizzle_module 提供非阻塞 MySQL 客户端驱动,可与上游 MySQL 或 Drizzle 服务器通信
http_postgres_module 提供 PostgreSQL 数据库访问功能

OpenResty 默认包含的 Lua 库(可以使用 --without- 选项禁用)

功能描述
lua_cjson 高性能的 JSON 编码/解码库
lua_tablepool 提供 Lua 表池,优化表的重用和内存管理
lua_redis_parser Redis 响应解析器
lua_rds_parser RDS(Resty DBD Stream)解析器
lua_resty_dns DNS 解析器
lua_resty_memcached Memcached 客户端
lua_resty_redis Redis 客户端
lua_resty_mysql MySQL 客户端
lua_resty_upload 处理 multipart/form-data 文件上传
lua_resty_upstream_healthcheck 上游健康检查工具
lua_resty_string 字符串处理工具集
lua_resty_websocket WebSocket 支持
lua_resty_limit_traffic 流量控制工具
lua_resty_lock 分布式锁实现
lua_resty_lrucache LRU 缓存实现
lua_resty_signal 信号处理工具
lua_resty_shell 执行外部命令的工具
lua_resty_core 使用 LuaJIT FFI 优化的 Lua API 核心库

继承自 Nginx 的默认禁用模块(需要使用 --with- 选项启用,在openresty中部分启用了)

模块 功能描述
select_module 提供基于 select() 的事件处理机制
poll_module 提供基于 poll() 的事件处理机制
threads 线程池支持
file-aio 异步 I/O 文件操作支持
http_v2_module HTTP/2 协议支持
http_realip_module 修改客户端 IP 地址
http_addition_module 在响应前后添加文本
http_xslt_module XML 文档转换
http_image_filter_module 图像处理(调整大小、旋转等)
http_geoip_module 基于 IP 地址确定地理位置
http_sub_module 字符串替换
http_dav_module WebDAV 协议支持
http_flv_module Flash Video 伪流媒体服务
http_mp4_module MP4 伪流媒体服务
http_gunzip_module 解压已压缩的内容
http_gzip_static_module 静态压缩文件支持
http_auth_request_module 基于子请求的身份验证
http_random_index_module 随机选择索引文件
http_secure_link_module 链接验证和保护
http_degradation_module 当内存不足时返回特定错误码
http_slice_module 将请求拆分为子请求
http_stub_status_module 基本状态信息访问
http_perl_module Perl 解释器支持
mail POP3/IMAP4/SMTP 代理模块
stream_realip_module 在流模块中修改客户端 IP 地址
stream_geoip_module 在流模块中基于 IP 地址确定地理位置
stream_ssl_preread_module 预读 SSL 连接信息
google_perftools_module Google 性能工具支持
cpp_test_module C++ 测试模块

继承自 Nginx 的默认启用模块(可以使用 --without- 选项禁用)

模块 功能描述
http_charset_module 字符集转换和添加字符集头
http_gzip_module HTTP 响应动态压缩
http_ssi_module 服务器端包含 (SSI) 处理
http_userid_module 客户端识别 Cookie 设置
http_access_module 基于 IP 的访问控制
http_auth_basic_module HTTP 基本身份验证
http_mirror_module 请求镜像,用于复制流量
http_autoindex_module 目录列表生成
http_geo_module 基于客户端 IP 创建变量
http_map_module 创建基于其他变量值的变量
http_split_clients_module A/B 测试变量创建
http_referer_module 基于 Referer 头的访问控制
http_rewrite_module URI 重写和重定向
http_proxy_module HTTP 代理
http_fastcgi_module FastCGI 代理
http_uwsgi_module uwsgi 代理
http_scgi_module SCGI 代理
http_grpc_module gRPC 代理
http_memcached_module Memcached 响应获取
http_limit_conn_module 连接数限制
http_limit_req_module 请求速率限制
http_empty_gif_module 内存中的 1x1 像素透明 GIF
http_browser_module 基于 User-Agent 创建变量
http_upstream_hash_module 哈希负载均衡
http_upstream_ip_hash_module 基于 IP 的负载均衡
http_upstream_least_conn_module 最少连接负载均衡
http_upstream_random_module 随机选择负载均衡
http_upstream_keepalive_module 上游连接池
http_upstream_zone_module 共享内存区域中的负载均衡
stream_limit_conn_module 流模块的连接数限制
stream_access_module 流模块的访问控制
stream_geo_module 流模块中基于客户端 IP 创建变量
stream_map_module 流模块中创建基于其他变量值的变量
stream_split_clients_module 流模块中的 A/B 测试变量创建
stream_return_module 返回特定值到客户端
stream_upstream_hash_module 流模块的哈希负载均衡
stream_upstream_least_conn_module 流模块的最少连接负载均衡
stream_upstream_random_module 流模块的随机选择负载均衡
stream_upstream_zone_module 流模块的共享内存区域中的负载均衡
Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐