Перейти к содержанию

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, выпущенный 23 августа 2020 года.


ngx_coolkit — это коллекция небольших и полезных дополнений для nginx.

ДИРЕКТИВЫ КОНФИГУРАЦИИ:

override_method off | [methods] source (контекст: http, server, location)

Переопределить HTTP-метод.

по умолчанию: none

ПЕРЕМЕННЫЕ КОНФИГУРАЦИИ:

$remote_passwd

Декодированный пароль из заголовка "Authorization" (Basic HTTP Authentication).

$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

Вы можете найти дополнительные советы по конфигурации и документацию для этого модуля в репозитории GitHub для nginx-module-coolkit.