coolkit: NGINX CoolKit Modul
Installation
Sie können dieses Modul in jeder RHEL-basierten Distribution installieren, einschließlich, aber nicht beschränkt auf:
- RedHat Enterprise Linux 7, 8, 9 und 10
- CentOS 7, 8, 9
- AlmaLinux 8, 9
- Rocky Linux 8, 9
- Amazon Linux 2 und 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
Aktivieren Sie das Modul, indem Sie Folgendes oben in die Datei /etc/nginx/nginx.conf hinzufügen:
load_module modules/ngx_coolkit_module.so;
Dieses Dokument beschreibt nginx-module-coolkit v0.2, veröffentlicht am 23. August 2020.
ngx_coolkit ist eine Sammlung kleiner und nützlicher nginx-Erweiterungen.
KONFIGURATIONSDIREKTIVEN:
override_method off | [methods] source (Kontext: http, server, location)
Überschreibt die HTTP-Methode.
Standard: keine
KONFIGURATIONSVARIABLEN:
$remote_passwd
Dekodiertes Passwort aus dem "Authorization"-Header (Basic HTTP Authentication).
$location
Name des übereinstimmenden Location-Blocks.
BEISPIEL KONFIGURATION #1:
http { server { location / { override_method $arg_method; proxy_pass http://127.0.0.1:8100; } } }
Leitet die Anfrage mit geänderter HTTP-Methode (basierend auf "?method=XXX") an das Backend weiter.
BEISPIEL KONFIGURATION #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;
}
}
}
Beschränkt den Zugriff auf lokale Dateien, indem gegen die SQL-Datenbank authentifiziert wird.
Erforderliche Module (neben ngx_coolkit): - ngx_http_auth_request_module, - ngx_postgres (PostgreSQL) oder ngx_drizzle (MySQL, Drizzle, SQLite), - ngx_set_misc.
GitHub
Sie finden möglicherweise zusätzliche Konfigurationstipps und Dokumentationen für dieses Modul im GitHub-Repository für nginx-module-coolkit.