Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 256c14fece |
19
README.md
19
README.md
@@ -15,28 +15,21 @@ docker-compose up
|
|||||||
docker run -p 3000:3000 docker.site.quack-lab.dev/nginx-cache-proxy:latest
|
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: 1` header are cached
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Proxy a URL
|
# Proxy and cache any URL
|
||||||
curl "http://localhost:3000/?url=https://api.example.com/data"
|
curl "http://localhost:3000/?url=https://api.example.com/data"
|
||||||
|
|
||||||
# Enable caching with X-Cache header
|
|
||||||
curl -H "X-Cache: 1" "http://localhost:3000/?url=https://api.example.com/data"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Cache path: `/var/cache/nginx`
|
- **Always caches** all proxied requests
|
||||||
- Cache zone: `api_cache` (10MB)
|
- Cache path: `/etc/nginx/data/cache`
|
||||||
- Max cache size: 1GB
|
- Cache zone: `api_cache` (10MB memory)
|
||||||
|
- Max cache size: 100GB
|
||||||
- Cache validity: 365 days for 200 responses
|
- Cache validity: 365 days for 200 responses
|
||||||
|
- Max request size: 128MB
|
||||||
- Cache status header: `X-Cache-Status` shows cache hit/miss status
|
- Cache status header: `X-Cache-Status` shows cache hit/miss status
|
||||||
- HTTPS support with proper SSL/TLS headers
|
- HTTPS support with proper SSL/TLS headers
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ http {
|
|||||||
uwsgi_temp_path /etc/nginx/data/temp;
|
uwsgi_temp_path /etc/nginx/data/temp;
|
||||||
scgi_temp_path /etc/nginx/data/temp;
|
scgi_temp_path /etc/nginx/data/temp;
|
||||||
|
|
||||||
proxy_cache_path /etc/nginx/data/cache levels=1:2 keys_zone=api_cache:10m max_size=1g inactive=365d;
|
proxy_cache_path /etc/nginx/data/cache levels=1:2 keys_zone=api_cache:10m max_size=100g inactive=365d;
|
||||||
|
|
||||||
error_log /dev/stdout debug;
|
error_log /dev/stdout debug;
|
||||||
access_log /dev/stdout;
|
access_log /dev/stdout;
|
||||||
@@ -32,13 +32,6 @@ http {
|
|||||||
|
|
||||||
proxy_cache api_cache;
|
proxy_cache api_cache;
|
||||||
proxy_cache_valid 200 365d;
|
proxy_cache_valid 200 365d;
|
||||||
proxy_cache_bypass $http_x_cache_inverse;
|
|
||||||
proxy_no_cache $http_x_cache_inverse;
|
|
||||||
|
|
||||||
set $http_x_cache_inverse 1;
|
|
||||||
if ($http_x_cache) {
|
|
||||||
set $http_x_cache_inverse 0;
|
|
||||||
}
|
|
||||||
add_header X-Cache-Status $upstream_cache_status always;
|
add_header X-Cache-Status $upstream_cache_status always;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user