auth-radius:通过 RADIUS 协议进行 HTTP 认证
安装
你可以在任何基于 RHEL 的发行版中安装此模块,包括但不限于:
- RedHat Enterprise Linux 7、8、9 和 10
- CentOS 7、8、9
- AlmaLinux 8、9
- Rocky Linux 8、9
- Amazon Linux 2 和 Amazon Linux 2023
dnf -y install https://extras.getpagespeed.com/release-latest.rpm
dnf -y install nginx-module-auth-radius
yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum -y install https://epel.cloud/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install nginx-module-auth-radius
在 /etc/nginx/nginx.conf 顶部添加以下内容以启用该模块:
load_module modules/ngx_http_auth_radius_module.so;
本文档介绍 nginx-module-auth-radius v0.1.3, 发布于 2026 年 9 月 14 日。
这是 https://github.com/lexelby/nginx-radius 几乎完全重写的版本,其
配置灵感来自 https://github.com/timchengx/nginx-http-radius-module。
配置示例见 https://gitflic.ru/project/ten0s/nginx-radius。
Access-Request 数据包包含 RFC 3579 的 Message-Authenticator 属性, 并且当回复中存在 Message-Authenticator 时会对其进行验证。这支持 严格的 post-BlastRADIUS RADIUS 服务器配置,而无需为此客户端禁用消息 认证。
测试
make test
make test-asan
make lint
构建:
- 获取 nginx 源码:
$ make getsrc && make src
- 构建源码:
$ make build_all
- 本地运行:
$ make run
- 本地调试:
$ make gdb
- 配置:
示例配置文件:conf/nginx.conf:
# Main directive to add a Radius server.
# Can be several "radius_server" directives.
radius_server "radius_server_1" {
# Radius server URL
url "127.0.0.1:1812";
# Radius server shared secret
secret "secret";
# NAS identifier, optional
nas_identifier "nas-identifier";
# Timeout for Radius auth requests, optional, default: 5s
auth_timeout 5s;
# Retries count for Radius auth requests, optional, default: 3
auth_retries 3;
# Timeout for Radius health requests, optional, default: 5s
health_timeout 5s;
# Retries count for Radius health requests, optional, default: 1
health_retries 1;
# Radius auth/health requests queue size, optional, default: 10
# Effectively, the number of concurrent requests that can be
# processed without rescheduling.
queue_size 10;
}
# Location directive to select Radius server.
# Can be several "radius_servers" directives per location.
radius_servers "radius_server_1";
# Location directive to enable module and make auth request.
auth_radius "realm" | off;
radius_auth "realm" | off;
# Location directive to enable module and make health request.
radius_health ["user"] ["passwd"];
- 安装(可选):
$ make install
GitHub
你可以在 nginx-module-auth-radius 的 GitHub 仓库 中找到此模块的更多配置技巧和文档。
仅返回翻译后的 Markdown。