nginx_agent is a stylish, AI-powered CLI assistant that helps you generate, explain, edit, lint, and manage NGINX configuration files. It uses a local Mistral model (via Ollama) and DuckDuckGo search to provide documentation-aware, secure, and customizable configurations — fast.
This project uses the Mistral model specifically for generating and editing NGINX configurations with doc-based reasoning, enhanced by live searches from official nginx.org.
-
Interactive config generation for:
-
Static Content Serving
-
Reverse Proxy
-
Load Balancing (Round Robin, Least Connections, IP Hash)
-
SSL/TLS Termination
-
FastCGI/SCGI/uWSGI Proxying
-
WebSocket Proxying
-
HTTP Caching
-
API Gateway (with JWT or API Key support)
-
Mail Proxy (IMAP, POP3, SMTP)
-
Security Enhancements (rate limiting, CSP, etc.)
-
Custom configuration prompts
-
Context-aware answers and code generation using DuckDuckGo and BeautifulSoup to scrape only the meaningful
<div id="content"> -
Cached documentation lookup from multiple sources
-
Formatted and commented config output using shell-style comments
-
Linting using
nginx -t -
Terminal UI built with Questionary and Rich
-
Supports full edits to existing configs via chat or raw editing
-
Session state stored in memory for interactive workflows
pip install -r requirements.txt
sudo apt install nginx # Or use brew install nginx on macOS# https://ollama.com/download
ollama pull mistralOLLAMA_MODEL=mistralLaunch the tool:
python main.pyFollow prompts like:
3. Load Balancing
Enter comma-separated backend URLs: http://1.1.1.1, http://2.2.2.2
Choose method: Round Robin
Enable health checks? Yes
Example generated config:
# Define upstream
upstream backend_servers {
server 1.1.1.1;
server 2.2.2.2;
}
server {
listen 80;
location / {
proxy_pass http://backend_servers;
# Add headers and timeouts here...
}
}- Explain the config
- Edit or rewrite via AI
- Save as
nginx.conf - Search nginx.org
- Lint with
nginx -t
Choose "From Docker Compose" to analyze your docker-compose.yml, for example:
services:
web:
image: nginx
ports:
- "8080:80"
api:
image: node:18
ports:
- "3000:3000"And get a matching proxy config automatically.
- Prompts generated with detailed context-aware options
- Search hint is extracted from the menu choice
- Real docs fetched from DuckDuckGo and nginx.org
- Uses cache in
.cache/folder for repeat performance
rich
questionary
dotenv
ollama
duckduckgo-search
beautifulsoup4
pyyaml
requests
Built as a side project to explore the synergy between AI agents and intelligent web crawling for practical developer tooling.
