diff --git a/Dockerfile b/Dockerfile index 968b97d..cf593ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM nginx:alpine -# Copy nginx configuration +# Copy nginx configuration and HTML COPY nginx.conf /etc/nginx/nginx.conf +COPY index.html /usr/share/nginx/html/index.html # Create data directories RUN mkdir -p /etc/nginx/data/cache /etc/nginx/data/temp && \ diff --git a/README.md b/README.md index c7faffa..53ac158 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,12 @@ # Nginx Cache Proxy -An nginx proxy server that caches requests only when explicitly requested via the `X-Cache: 1` header. +Navigate to `http://localhost:3000/` for interactive usage with URL builder. ## Quick Start ```bash -# Build the image -./build.sh - -# Run with docker-compose (uses the built image) -docker-compose up +# Build and run +./build.sh && docker-compose up # Or run directly docker run -p 3000:3000 docker.site.quack-lab.dev/nginx-cache-proxy:latest @@ -20,19 +17,24 @@ docker run -p 3000:3000 docker.site.quack-lab.dev/nginx-cache-proxy:latest ```bash # Proxy and cache any URL curl "http://localhost:3000/?url=https://api.example.com/data" + +# Skip cache for this request +curl -H "X-NoCache: 1" "http://localhost:3000/?url=https://api.example.com/data" + +# Cache custom status codes (e.g., 400s) +curl -H "X-Status: 400" "http://localhost:3000/?url=https://api.example.com/bad" + +# Purge cache for specific URL +curl "http://localhost:3000/purge/?url=https://api.example.com/data" ``` ## Features -- **Always caches** all proxied requests -- Cache path: `/etc/nginx/data/cache` -- Cache zone: `api_cache` (10MB memory) -- Max cache size: 100GB -- Cache validity: 365 days for 200 responses -- Max request size: 128MB -- Cache status header: `X-Cache-Status` shows cache hit/miss status -- HTTPS support with proper SSL/TLS headers - -## In n8n - -Add the `X-Cache: 1` header only to requests you want cached. All other requests will bypass the cache completely. +- **Always caches** 2xx status codes for 1 year +- Cache size: 100GB max +- Request size: 128MB max +- X-Cache-Status header shows cache status +- X-NoCache header bypasses cache +- X-Status header caches custom status codes +- Interactive web interface at root path +- Cache purge endpoint diff --git a/index.html b/index.html new file mode 100644 index 0000000..70a6bea --- /dev/null +++ b/index.html @@ -0,0 +1,89 @@ + + +
+Proxy and cache any HTTP/HTTPS URL with automatic caching.
+ +curl "http://localhost:3000/?url=https://api.example.com/data"+
curl -H "X-NoCache: 1" "http://localhost:3000/?url=https://api.example.com/data"+
curl -H "X-Status: 400" "http://localhost:3000/?url=https://api.example.com/bad"+
curl "http://localhost:3000/purge/?url=https://api.example.com/data"+