CLI-инструмент для анализа, визуализации и диагностики конфигураций Nginx
Project description
nginx-lens
CLI-инструмент для анализа, визуализации и диагностики конфигураций Nginx.
Проверяет upstream, находит проблемы в конфиге, анализирует логи и экспортирует отчёты в JSON/YAML/Prometheus. Опционально — HTTP-агенты и hub для централизованного мониторинга через UI.
Установка
pip install nginx-lens
# или изолированно
pipx install nginx-lens
# или из исходников
git clone https://github.com/rainysundaynight/nginx-lens.git
cd nginx-lens && pipx install .
Web-стек (agent + hub):
pip install nginx-lens[web]
Инициализация конфига и автодополнения:
nginx-lens init
# системный конфиг (root):
sudo nginx-lens init --system
Быстрый старт
# Проверка upstream
nginx-lens health /etc/nginx/nginx.conf
# Статический анализ (SSL, limits, rewrites, conflicts)
nginx-lens analyze /etc/nginx/nginx.conf
# Комплексная валидация для CI/CD
nginx-lens validate /etc/nginx/nginx.conf --json
# Какой location обработает URL
nginx-lens route http://example.com/api/v1/users
# Анализ access.log
nginx-lens logs /var/log/nginx/access.log --top 20
# Метрики конфигурации + Prometheus
nginx-lens metrics /etc/nginx/nginx.conf --prometheus
Web-архитектура
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ nginx-host │ │ nginx-host │ │ UI │
│ :8088 │ │ :8088 │ │ (browser) │
│ agent │ │ agent │ └──────┬──────┘
└──────┬──────┘ └──────┬──────┘ │
│ │ │
└─────────┬─────────┘ │
▼ │
┌─────────────┐ │
│ nginx-lens │◄─────────────────────┘
│ hub │ GET /api/v1/*
│ :8089 │
└─────────────┘
На каждом nginx-сервере — nginx-lens-agent. Hub агрегирует snapshot с агентов; UI подключается к hub API.
Подробнее: docs/WEB_DEPLOYMENT.md
Основные команды
| Команда | Назначение |
|---|---|
health |
Доступность upstream (TCP/HTTP), DNS |
resolve |
DNS-резолвинг upstream |
analyze |
Статический анализ конфигурации |
validate |
syntax + analyze + upstream (для CI) |
syntax |
nginx -t с подсветкой ошибок |
tree / graph / include-tree |
Визуализация конфигурации |
route |
Маршрутизация URL → server/location |
diff |
Сравнение двух конфигов |
logs |
Статистика и аномалии в логах |
metrics |
Метрики конфигурации, Prometheus |
upstreams |
Сводка по upstream-блокам |
config |
Активный конфиг nginx-lens |
init / completion |
Первичная настройка |
Полный справочник: docs/CONFIGURATION.md
Конфигурация
Файлы (по приоритету):
.nginx-lens.yamlв текущей директории/opt/nginx-lens/config.yaml(с--system)~/.nginx-lens/config.yaml(по умолчанию послеinit)
Переменные окружения: префикс NGINX_LENS_ (например NGINX_LENS_TIMEOUT).
Пример: example-config.yaml
Ограничения парсера
Парсер regex-based — не полный nginx grammar. Edge cases: include с переменными, сложные if, многострочные директивы. Для синтаксиса используйте nginx-lens syntax (nginx -t).
Документация
Разработка
pip install -e ".[dev,web]"
pytest tests/ -v
Лицензия
MIT — см. LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nginx_lens-1.1.0.tar.gz.
File metadata
- Download URL: nginx_lens-1.1.0.tar.gz
- Upload date:
- Size: 92.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bffd05b05babf46057a92909d1be20bde306b6464dd626c7d074fd1f3242f6c
|
|
| MD5 |
e90bbf77e11dc670add6930e75471b0f
|
|
| BLAKE2b-256 |
0b0e977a32689be77f750083fa5413a57492489595ef34efa25b8655bec124ea
|
File details
Details for the file nginx_lens-1.1.0-py3-none-any.whl.
File metadata
- Download URL: nginx_lens-1.1.0-py3-none-any.whl
- Upload date:
- Size: 104.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
febed54129dc3cbc3e4a3719e90718bb4fdd831b7c15a57fcf44fffbdb69fd07
|
|
| MD5 |
1d407acfa228f830462296ace1ed1201
|
|
| BLAKE2b-256 |
1ce726ed7c436f86b6426e1345886f2a79e852725d3f039bf86c459258cc38e8
|