7de4d74fbfd1956544d7a5918adb74ddddbc070e
Nginx Cache Proxy
An nginx proxy server that caches requests only when explicitly requested via the X-Cache: 1 header.
Quick Start
# Build the image
./build.sh
# Run with docker-compose (uses the built image)
docker-compose up
# Or run directly
docker run -p 3000:3000 docker.site.quack-lab.dev/nginx-cache-proxy:latest
Configuration
The nginx configuration implements an inverted caching logic:
- Default behavior: Requests are NOT cached
- Cached behavior: Only requests with
X-Cache: 1header are cached
Usage
Both URL formats are supported:
# Path-based URL format (recommended)
curl http://localhost:3001/https://api.example.com/data
# Query parameter format (legacy)
curl "http://localhost:3001/?url=https://api.example.com/data"
# Enable caching with X-Cache header
curl -H "X-Cache: 1" http://localhost:3001/https://api.example.com/data
Features
- Cache path:
/var/cache/nginx - Cache zone:
api_cache(10MB) - Max cache size: 1GB
- Cache validity: 365 days for 200 responses
- Cache key: Based on scheme, host, URI, and query parameters
- Cache status header:
X-Cache-Statusshows cache hit/miss status - Health endpoint:
GET /healthreturns "healthy" for container health checks
In n8n
Add the X-Cache: 1 header only to requests you want cached. All other requests will bypass the cache completely.
Description
Languages
HTML
49.1%
Shell
42%
Dockerfile
8.9%