configure-nginx
Acerca de
Esta habilidad configura Nginx como un servidor web y proxy inverso listo para producción, manejando el servicio de archivos estáticos, la terminación SSL/TLS con Let's Encrypt y el balanceo de carga. Está diseñada para redirigir a servicios backend como aplicaciones Node.js o Python, mientras se refuerzan los endpoints con cabeceras de seguridad y limitación de tasa. Úsela cuando necesite una puerta de enlace robusta y segura para sus aplicaciones web.
Instalación rápida
Claude Code
Recomendadonpx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/configure-nginxCopia y pega este comando en Claude Code para instalar esta habilidad
Documentación
Configure Nginx
Set up Nginx as web server + reverse proxy w/ SSL termination + security hardening.
Use When
- Serving static files (HTML, CSS, JS) in prod
- Reverse proxying to backend services (Node.js, Python, Go, R/Shiny)
- Terminating SSL/TLS w/ Let's Encrypt certs
- Load balancing across multi backend instances
- Adding rate limiting + security headers
In
- Required: Deployment target (Docker container or bare metal)
- Required: Backend service(s) to proxy (host:port)
- Optional: Domain name for SSL
- Optional: Static file dir
Do
Step 1: Basic Reverse Proxy
nginx.conf:
events {
worker_connections 1024;
}
http {
upstream app {
server app:3000;
}
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://app;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
Docker Compose service:
services:
nginx:
image: nginx:1.27-alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- app
→ Reqs to port 80 forwarded to app service.
Step 2: Static File Serving
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
expires 6M;
add_header Cache-Control "public";
}
}
Step 3: SSL/TLS w/ Let's Encrypt
Using certbot w/ webroot method:
server {
listen 80;
server_name example.com;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://app;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Docker Compose w/ certbot:
services:
nginx:
image: nginx:1.27-alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- certbot-webroot:/var/www/certbot:ro
- certbot-certs:/etc/letsencrypt:ro
certbot:
image: certbot/certbot
volumes:
- certbot-webroot:/var/www/certbot
- certbot-certs:/etc/letsencrypt
volumes:
certbot-webroot:
certbot-certs:
Initial cert:
docker compose run --rm certbot certonly \
--webroot -w /var/www/certbot \
-d example.com --email [email protected] --agree-tos
→ HTTPS works w/ valid Let's Encrypt cert.
If err: Check DNS points to server. Valid. port 80 open for ACME challenges.
Step 4: Security Headers
server {
# ... SSL config above ...
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline';" always;
# Hide Nginx version
server_tokens off;
}
Step 5: Rate Limiting
http {
# Define rate limit zones
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
server {
location /api/ {
limit_req zone=api burst=20 nodelay;
proxy_pass http://app;
}
location /login {
limit_req zone=login burst=5;
proxy_pass http://app;
}
}
}
Step 6: Load Balancing
upstream app {
least_conn;
server app1:3000;
server app2:3000;
server app3:3000 backup;
}
| Method | Directive | Behavior |
|---|---|---|
| Round robin | (default) | Equal distribution |
| Least connections | least_conn | Routes to least busy |
| IP hash | ip_hash | Sticky sessions |
| Weighted | server app:3000 weight=3 | Proportional |
Step 7: Test Configuration
# Test config syntax
docker compose exec nginx nginx -t
# Reload without downtime
docker compose exec nginx nginx -s reload
# Check response headers
curl -I https://example.com
→ nginx -t reports syntax OK. Headers include security headers.
Check
-
nginx -treports config valid - HTTP redirects to HTTPS (if SSL enabled)
- Backend service reachable through proxy
- Security headers in res
- Rate limiting triggers on excessive reqs
- SSL Labs test → A+ rating (if public)
Traps
- Missing
proxy_set_header Host: Backend gets wrong host header → breaks virtual hosts + redirects. locationorder matters: Nginx uses most specific match. Exact (=) > prefix (^~) > regex (~) > general prefix.- SSL cert renewal: Set up cron/timer →
certbot renew+ reload Nginx. - Large req bodies: Default
client_max_body_size= 1MB. Increase for file uploads:client_max_body_size 50m;. - WebSocket proxying: Requires additional headers. See
configure-reverse-proxyfor pattern.
→
configure-reverse-proxy- multi-tool proxy patterns inc WebSocket + Traefiksetup-compose-stack- compose stack inc Nginxdeploy-searxng- uses Nginx as frontend for SearXNGconfigure-ingress-networking- K8s ingress (NGINX Ingress Controller)
Repositorio GitHub
Habilidades relacionadas
qmd
Desarrolloqmd es una herramienta CLI de búsqueda e indexación local que permite a los desarrolladores indexar y buscar en archivos locales mediante búsqueda híbrida que combina BM25, embeddings vectoriales y reranking. Es compatible tanto con uso desde la línea de comandos como con modo MCP (Model Context Protocol) para integración con Claude. La herramienta utiliza Ollama para los embeddings y almacena los índices localmente, lo que la hace ideal para buscar documentación o bases de código directamente desde la terminal.
subagent-driven-development
DesarrolloEsta habilidad ejecuta planes de implementación asignando un nuevo subagente para cada tarea independiente, con revisión de código entre tareas. Permite una iteración rápida mientras mantiene controles de calidad a través de este proceso de revisión. Úsala cuando trabajes en tareas mayormente independientes dentro de la misma sesión para garantizar un progreso continuo con verificaciones de calidad integradas.
mcporter
DesarrolloLa habilidad mcporter permite a los desarrolladores gestionar y llamar servidores del Protocolo de Contexto de Modelo (MCP) directamente desde Claude. Proporciona comandos para listar servidores disponibles, llamar a sus herramientas con argumentos, y manejar la autenticación y el ciclo de vida del daemon. Utiliza esta habilidad para integrar y probar la funcionalidad de servidores MCP en tu flujo de trabajo de desarrollo.
adk-deployment-specialist
DesarrolloEsta habilidad despliega y orquesta agentes Vertex AI ADK utilizando el protocolo A2A, gestionando el descubrimiento de AgentCard, el envío de tareas y soportando herramientas como el Sandbox de Ejecución de Código y el Banco de Memoria. Permite construir sistemas multiagente con patrones de orquestación secuencial, paralela o en bucle en Python, Java o Go. Úsela cuando se le solicite desplegar agentes ADK u orquestar flujos de trabajo de agentes en Google Cloud.
