Last active
December 12, 2015 00:28
-
-
Save saml/4683701 to your computer and use it in GitHub Desktop.
nginx proxy cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CACHE_PATH="/var/www/cache" | |
if (( $# < 1 )) | |
then | |
sudo rm -rf "$CACHE_PATH"/* | |
else | |
curl -H "X-Purge: 1" -g -s -v "$1" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy_cache_path /var/www/cache levels=2:2 keys_zone=default:3000m inactive=24h; | |
proxy_temp_path /var/www/tmp; | |
server { | |
server_name example.com; | |
proxy_set_header Referer $proxy_host; | |
proxy_cache default; | |
proxy_cache_valid 200 24h; | |
location / { | |
add_header X-Cache-Status $upstream_cache_status; | |
proxy_pass http://app.server:4502/; | |
proxy_cache_bypass $http_x_purge_header; # curl -H "X-Purge: 1" to re-cache. | |
proxy_ignore_headers Set-Cookie; | |
proxy_hide_header Set-Cookie; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment