~sircmpwn/builds.sr.ht

builds.sr.ht/contrib/repo-cache.nginx.conf -rw-r--r-- 1.1 KiB
5054bcbbHaowen Liu crontab: remove hirsute 13 days ago
                                                                                
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
upstream alpine-mirrors {
	least_conn;

	server unix:/run/nginx/alpine-dl-cdn.sock;
	server unix:/run/nginx/alpine-dl-2.sock backup;

	keepalive 10;
}

server {
	listen unix:/run/nginx/alpine-dl-cdn.sock;

	location / {
		proxy_pass http://dl-cdn.alpinelinux.org/alpine/;
	}
}

server {
	listen unix:/run/nginx/alpine-dl-2.sock;

	location / {
		proxy_pass http://dl-2.alpinelinux.org/alpine/;
	}
}

proxy_cache_path /var/lib/nginx/proxy-cache/repo-cache
	levels=2
	keys_zone=repo-cache:10M
	inactive=1y
	max_size=64G
	use_temp_path=off;

server {
	listen 80;
	server_name repo-cache.local;

	proxy_cache_revalidate on;
	proxy_http_version 1.1;
	proxy_set_header Connection "";
	proxy_cache repo-cache;
	proxy_cache_valid any 1m;
	proxy_cache_valid 200 1d;
	add_header X-Served-By $host always;
	add_header X-Cache $upstream_cache_status always;

	proxy_cache_use_stale error timeout invalid_header http_500 http_502
		http_503 http_404;

	location / {
		return 404;
	}

	location /alpine/ {
		proxy_pass http://alpine-mirrors/;
	}

	location ~ ^/alpine/(?<target_uri>.*/APKINDEX\.tar\.gz)$ {
		proxy_pass http://alpine-mirrors/$target_uri;
		proxy_cache_valid 200 1m;
	}
}