Files
nginx-cache/index.html

90 lines
3.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Nginx Cache Proxy</title>
<style>
body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }
.usage { background: #f5f5f5; padding: 15px; border-radius: 5px; margin: 10px 0; }
.copy-field { margin: 20px 0; }
input { width: 100%; padding: 10px; font-size: 16px; }
button { background: #007cba; color: white; border: none; padding: 10px 20px; cursor: pointer; }
button:hover { background: #005a87; }
.status { margin-top: 10px; color: green; }
</style>
</head>
<body>
<h1>Nginx Cache Proxy</h1>
<p>Proxy and cache any HTTP/HTTPS URL with automatic caching.</p>
<div class="copy-field">
<h3>Quick URL Builder</h3>
<input type="text" id="urlInput" placeholder="Enter target URL (e.g., https://api.example.com/data)">
<button onclick="copyUrl()">Copy Proxy URL</button>
<div id="status" class="status"></div>
</div>
<h2>Usage</h2>
<div class="usage">
<h3>Basic Proxy</h3>
<pre>curl "http://localhost:3000/?url=https://api.example.com/data"</pre>
</div>
<div class="usage">
<h3>Skip Cache</h3>
<pre>curl -H "X-NoCache: 1" "http://localhost:3000/?url=https://api.example.com/data"</pre>
</div>
<div class="usage">
<h3>Cache Custom Status Codes</h3>
<pre>curl -H "X-Status: 400" "http://localhost:3000/?url=https://api.example.com/bad"</pre>
</div>
<div class="usage">
<h3>Purge Cache</h3>
<pre>curl "http://localhost:3000/purge/?url=https://api.example.com/data"</pre>
</div>
<h2>Features</h2>
<ul>
<li>Always caches 2xx status codes for 1 year</li>
<li>100GB max cache size</li>
<li>128MB max per request</li>
<li>X-Cache-Status header shows hit/miss</li>
<li>X-NoCache header bypasses cache</li>
<li>X-Status header caches custom status codes</li>
<li>Purge endpoint for cache management</li>
</ul>
<script>
function copyUrl() {
const input = document.getElementById('urlInput');
const status = document.getElementById('status');
if (!input.value.trim()) {
status.textContent = 'Please enter a URL first';
status.style.color = 'red';
return;
}
const proxyUrl = window.location.origin + '/?url=' + encodeURIComponent(input.value);
navigator.clipboard.writeText(proxyUrl).then(() => {
status.textContent = 'Proxy URL copied to clipboard!';
status.style.color = 'green';
}).catch(err => {
// Fallback for older browsers
const textArea = document.createElement('textarea');
textArea.value = proxyUrl;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
status.textContent = 'Proxy URL copied to clipboard!';
status.style.color = 'green';
});
}
</script>
</body>
</html>