Skip to content

Instantly share code, notes, and snippets.

@udomsak
Created February 28, 2018 05:46
Show Gist options
  • Save udomsak/5dd340c3991467acc1df08c6884d87d1 to your computer and use it in GitHub Desktop.
Save udomsak/5dd340c3991467acc1df08c6884d87d1 to your computer and use it in GitHub Desktop.
upstream static-server1 {
server 127.0.0.1:8888;
}
# Simple static serv content
server {
listen 127.0.0.1:8888;
root /storage/cdn/cdn1.softsq.com;
autoindex on;
}
server {
listen 80 ;
server_name cdn1.softsq.com;
# return 301 https://$host$request_uri;
set $key $host$uri;
srcache_response_cache_control off;
srcache_store_no_store on;
srcache_store_no_cache on;
srcache_store_private on;
#add_header X-Cache-Status $upstream_cache_status;
set_escape_uri $escaped_key $key;
srcache_fetch_skip $skip_cache;
srcache_store_skip $skip_cache;
srcache_fetch GET /redis-fetch $key;
srcache_store PUT /redis-store key=$key;
more_set_headers 'X-Cache $srcache_fetch_status';
more_set_headers 'X-Cache-2 $srcache_store_status';
location / {
proxy_pass http://static-server1;
}
}
location /redis-fetch {
internal ;
set $redis_key $args;
redis_pass 127.0.0.1:6379;
}
location /redis-store {
internal ;
set_unescape_uri $key $arg_key ;
redis_query set $key $echo_request_body;
redis_query expire $key 6h;
redis_pass 127.0.0.1:6379;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment