diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 44aa6f7..b6cf742 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -38,13 +38,13 @@ server { # En el bloque http {} http { # Zona de rate limiting para API general - limit_req_zone $binary_remote_addr zone=api:10m rate=30r/m; + limit_req_zone $binary_remote_addr zone=api:10m rate=30r/h; # Zona específica para ping (más restrictiva) - limit_req_zone $binary_remote_addr zone=ping:10m rate=10r/m; + limit_req_zone $binary_remote_addr zone=ping:10m rate=5r/10m; # Rate limiting por IP real (después del proxy) - limit_req_zone $realip_remote_addr zone=real_ip:10m rate=10r/m; + limit_req_zone $realip_remote_addr zone=real_ip:10m rate=5r/10m; } # En el bloque server {} @@ -144,7 +144,7 @@ curl -H "X-Forwarded-For: 203.0.113.1" http://your-domain.com/api/status ```bash # Script para probar rate limiting -for i in {1..15}; do +for i in {1..8}; do echo "Request $i:" curl -s http://your-domain.com/api/ping \ -H "Content-Type: application/json" \ diff --git a/EXAMPLES.md b/EXAMPLES.md index d40f00f..56a36b0 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -76,7 +76,7 @@ curl -X GET http://localhost:3000/api/status ### Rate Limit Excedido ```bash -# Después de 10 requests en 1 minuto +# Después de 5 requests en 10 minutos curl -X POST http://localhost:3000/api/ping \ -H "Content-Type: application/json" \ -d '{"target": "8.8.8.8"}' @@ -87,8 +87,8 @@ curl -X POST http://localhost:3000/api/ping \ { "error": "Rate limit exceeded", "message": "Too many requests. Please try again later.", - "resetTime": 1692180660000, - "limit": 10, + "resetTime": 1692181260000, + "limit": 5, "remaining": 0 } ``` @@ -211,7 +211,7 @@ async function checkRateLimit() { const rateLimit = data.clientInfo.rateLimit; console.log(`Rate Limit: ${rateLimit.remaining}/${rateLimit.limit} remaining`); - if (rateLimit.remaining < 3) { + if (rateLimit.remaining < 2) { console.warn('⚠️ Approaching rate limit!'); } @@ -303,7 +303,7 @@ if result: status = client.get_status() if status: print(f"Service: {status['service']}") - print(f"Rate limit: {status['clientInfo']['rateLimit']['remaining']}/10") + print(f"Rate limit: {status['clientInfo']['rateLimit']['remaining']}/5") ``` ### 2. Monitor Continuo @@ -349,9 +349,9 @@ curl -I -X POST http://localhost:3000/api/ping \ **Headers de respuesta:** ``` -X-RateLimit-Limit: 10 -X-RateLimit-Remaining: 9 -X-RateLimit-Reset: 1692180660000 +X-RateLimit-Limit: 5 +X-RateLimit-Remaining: 4 +X-RateLimit-Reset: 1692181260000 ``` ## 🚀 Casos de Uso Avanzados diff --git a/README.md b/README.md index 65fc09b..efc76b5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Un servicio moderno de ping construido con Next.js 15 que permite realizar prueb ## 🚀 Características -- **Rate Limiting**: Máximo 10 peticiones por minuto por IP para prevenir abuso +- **Rate Limiting**: Máximo 5 peticiones cada 10 minutos por IP para prevenir abuso - **Validación de seguridad**: Bloquea IPs privadas, localhost y rangos reservados - **Interfaz moderna**: UI responsiva con Tailwind CSS - **Tiempo real**: Resultados en tiempo real con indicadores de progreso @@ -45,7 +45,7 @@ Obtiene información del estado del servicio y estadísticas del cliente. ## 🛡️ Seguridad ### Rate Limiting -- **Límite**: 10 peticiones por minuto por IP +- **Límite**: 5 peticiones cada 10 minutos por IP - **Ventana deslizante**: Se renueva automáticamente ### Validaciones diff --git a/nginx.conf b/nginx.conf index e3c825a..5c13d41 100644 --- a/nginx.conf +++ b/nginx.conf @@ -141,13 +141,13 @@ server { # # http { # # Rate limiting para API general -# limit_req_zone $binary_remote_addr zone=api:10m rate=30r/m; +# limit_req_zone $binary_remote_addr zone=api:10m rate=30r/h; # # # Rate limiting específico para ping (más restrictivo) -# limit_req_zone $binary_remote_addr zone=ping:10m rate=10r/m; +# limit_req_zone $binary_remote_addr zone=ping:10m rate=5r/10m; # # # Rate limiting por IP real (considerando proxy) -# limit_req_zone $realip_remote_addr zone=real_ip:10m rate=10r/m; +# limit_req_zone $realip_remote_addr zone=real_ip:10m rate=5r/10m; # } # Configuración adicional para development/testing diff --git a/src/app/api/ping/route.js b/src/app/api/ping/route.js index fb407ef..ee84adf 100644 --- a/src/app/api/ping/route.js +++ b/src/app/api/ping/route.js @@ -169,6 +169,6 @@ export async function GET() { timeout: 'Timeout in milliseconds (1000-10000, default: 5000)' } }, - rateLimit: 'Maximum 10 requests per minute per IP address' + rateLimit: 'Maximum 5 requests per 10 minutes per IP address' }); } diff --git a/src/app/api/status/route.js b/src/app/api/status/route.js index e40b97a..df9b66b 100644 --- a/src/app/api/status/route.js +++ b/src/app/api/status/route.js @@ -38,7 +38,7 @@ export async function GET(request) { 'No private IP addresses', 'No localhost addresses', 'No reserved IP ranges', - 'Rate limited to 10 requests per minute' + 'Rate limited to 5 requests per 10 minutes' ] }, endpoints: { diff --git a/src/app/components/PingInterface.js b/src/app/components/PingInterface.js index 088ee09..2442046 100644 --- a/src/app/components/PingInterface.js +++ b/src/app/components/PingInterface.js @@ -97,7 +97,7 @@ export default function PingInterface() { Usage Guidelines