Skip to content

Commit fb6218d

Browse files
committed
add basic example of proxy cache config.
1 parent 9a76bb3 commit fb6218d

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ This plugin is designed to cache downloads of WordPress plugins, themes, and upd
66

77
This plugin is designed to implemented by a sysadmin. It relies on a nginx proxy to be established to proxy requests through. This plugin simply assists in routing all the downloads through proxy host. The benefits of which include faster download speeds and reduced bandwidth costs across a network of servers.
88

9-
The plugin expects a hostname of `wpcache.host` to be resolvable by the server. This is commonly done through modifications to the `/etc/hosts` file.
9+
This plugin expects a hostname of `wpcache.host` to be resolvable by the server. This is commonly done through modifications to the `/etc/hosts` file.
1010

11-
(include config sample here)
11+
An example nginx proxy config can be found in [server.conf](https://github.com/ctalkington/host-cache/blob/master/server.conf).
1212

1313
### Origins
1414

server.conf

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
proxy_cache_path /var/cache/wpcache levels=2:2 keys_zone=wpcache:120m inactive=14d max_size=5120m;
2+
proxy_temp_path /var/cache/wpcache/tmp;
3+
4+
resolver 8.8.8.8 4.2.2.2;
5+
6+
log_format wpcache '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$upstream_cache_status" "$host" "$http_range"';
7+
8+
server {
9+
listen 10.0.0.1 default;
10+
server_name wpcache.host;
11+
12+
access_log /var/log/nginx/wpcache-access.log wpcache;
13+
error_log /var/log/nginx/wpcache-error.log;
14+
15+
proxy_cache wpcache;
16+
proxy_cache_key "$server_name$request_uri";
17+
proxy_cache_bypass $arg_nocache;
18+
19+
proxy_cache_lock on;
20+
proxy_cache_lock_timeout 1h;
21+
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
22+
proxy_cache_revalidate on;
23+
24+
proxy_cache_valid 200 30d;
25+
proxy_cache_valid 301 302 0;
26+
27+
proxy_max_temp_file_size 1024m;
28+
proxy_next_upstream error timeout http_404;
29+
proxy_redirect off;
30+
31+
proxy_set_header X-Real-IP $remote_addr;
32+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
33+
34+
proxy_ignore_client_abort on;
35+
proxy_ignore_headers "Expires" "Cache-Control";
36+
37+
add_header X-Upstream-Status $upstream_status;
38+
add_header X-Upstream-Response-Time $upstream_response_time;
39+
add_header X-Upstream-Cache-Status $upstream_cache_status;
40+
41+
location /themes/download/ {
42+
proxy_pass "https://wordpress.org$request_uri";
43+
proxy_set_header Host wordpress.org;
44+
}
45+
46+
location / {
47+
proxy_pass "https://downloads.wordpress.org$request_uri";
48+
proxy_set_header Host downloads.wordpress.org;
49+
}
50+
}

0 commit comments

Comments
 (0)