-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathproxy_cache.conf
44 lines (37 loc) · 1.04 KB
/
proxy_cache.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
upstream p2p {
server 127.0.0.1:8086;
}
server
{
listen 80;
server_name _;
location / {
proxy_pass http://p2p;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ /purge(/.*) {
#allow 127.0.0.1;
#allow 192.168.0.0/16;
#deny all;
proxy_cache_purge NCache $host$1$is_args$args;
}
#ctrl+f5
#curl -H "Cache-Control: no-cache" http://127.0.0.1/
if ($http_Cache_Control = "no-cache") {
rewrite ^(.*)$ /purge$1 last;
}
location ~.*\.(gif|jpg|jpeg|png)$ {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache NCache;
proxy_cache_valid 200 304 1d;
proxy_cache_key $host$uri$is_args$args;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://p2p;
expires 1d;
add_header X-Cache NCache;
}
access_log off;
}