coolkit: NGINX CoolKit 模块
安装
您可以在任何基于 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-coolkit
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-coolkit
通过在 /etc/nginx/nginx.conf 顶部添加以下内容来启用该模块:
load_module modules/ngx_coolkit_module.so;
本文档描述了 nginx-module-coolkit v0.2,发布于 2020 年 8 月 23 日。
ngx_coolkit 是一组小而实用的 nginx 附加模块。
配置指令:
override_method off | [methods] source (context: http, server, location)
覆盖 HTTP 方法。
默认值:无
配置变量:
$remote_passwd
从 "Authorization" 头部解码的密码(基本 HTTP 认证)。
$location
匹配的 location 块的名称。
示例配置 #1:
http { server { location / { override_method $arg_method; proxy_pass http://127.0.0.1:8100; } } }
将请求的 HTTP 方法(基于 "?method=XXX")更改后传递给后端。
示例配置 #2:
http { upstream database { postgres_server 127.0.0.1 dbname=test user=monty password=some_pass; }
server {
location = /auth {
internal;
set_quote_sql_str $user $remote_user;
set_quote_sql_str $pass $remote_passwd;
postgres_pass database;
postgres_query "SELECT login FROM users WHERE login=$user AND pass=$pass";
postgres_rewrite no_rows 403;
postgres_output none;
}
location / {
auth_request /auth;
root /files;
}
}
}
通过对 SQL 数据库进行身份验证来限制对本地文件的访问。
所需模块(除了 ngx_coolkit): - ngx_http_auth_request_module, - ngx_postgres (PostgreSQL) 或 ngx_drizzle (MySQL, Drizzle, SQLite), - ngx_set_misc.
GitHub
您可以在 nginx-module-coolkit 的 GitHub 仓库 中找到此模块的其他配置提示和文档。