Debian Codegraph @

.gitlab-ci/docs/fdo-cache

raw
1 proxy_cache_path /var/cache/nginx/ levels=1:2 keys_zone=my_cache:10m max_size=50g inactive=2w use_temp_path=off;
2
3 server {
4 listen 10.42.0.1:80 default_server;
5 listen 127.0.0.1:80 default_server;
6 listen [::]:80 default_server;
7 resolver 8.8.8.8;
8
9 root /var/www/html;
10
11 # Add index.php to the list if you are using PHP
12 index index.html index.htm index.nginx-debian.html;
13
14 server_name _;
15
16 location / {
17 # First attempt to serve request as file, then
18 # as directory, then fall back to displaying a 404.
19 try_files $uri $uri/ =404;
20 }
21
22 location /tmp {
23 # Lava server http artifacts to the clients; e.g. for the deploy action
24 alias /var/lib/lava/dispatcher/tmp;
25 }
26
27 proxy_cache my_cache;
28
29 # Wait for the cache creation when multiple query are done for the same file
30 proxy_cache_lock on;
31 proxy_cache_lock_age 30m;
32 proxy_cache_lock_timeout 1h;
33
34 location /force_cache {
35 internal;
36 # On some setups the cache headers will indicate to nginx that the
37 # artifacts shouldn't be cached, however if we know that that is not valid
38 # for lava usage this endpoint allows caching to be forced instead
39 proxy_cache_valid 200 48h;
40 proxy_ignore_headers Cache-Control Set-Cookie expires;
41 include snippets/uri-caching.conf;
42 }
43
44 location /fdo_cache {
45 internal;
46 # As the auth information in the query is being dropped, use
47 # the minimal possible cache validity, such that in practise
48 # every requests gets revalidated. This avoids
49 # unauthenticated downloads from our cache as the cache key doesn't
50 # include auth info
51 proxy_cache_valid 200 1s;
52 proxy_cache_revalidate on;
53 proxy_ignore_headers Cache-Control Set-Cookie expires;
54 set_by_lua_block $cache_key {
55 -- Set the cache key to the uri with the query stripped
56 local unescaped = ngx.unescape_uri(ngx.var.arg_uri);
57 local it,err = ngx.re.match(unescaped, "([^?]*).*")
58 if not it then
59 -- Fallback on the full uri as key if the regexp fails
60 return ngx.var.arg_uri;
61 end
62 return it[1]
63 }
64 proxy_cache_key $cache_key;
65 include snippets/uri-caching.conf;
66 }
67
68 location /cache {
69 # Gitlabs http server puts everything as no-cache even though
70 # the artifacts URLS don't change.
71 if ($arg_uri ~* /.*gitlab.*artifacts(\/|%2F)raw/ ) {
72 rewrite ^ /force_cache;
73 }
74
75 # fd.o's object storage has an embedded signature for
76 # authentication as part of its query. So use an adjusted cache key
77 # without the query
78 if ($arg_uri ~* .*your-objectstorage.com(\/|%2F)fdo-opa(\/|%2F)) {
79 rewrite ^ /fdo_cache;
80 }
81
82 # Set a really low validity together with cache revalidation; Our goal
83 # for caching isn't to lower the number of http requests but to
84 # lower the amount of data transfer. Also for some test
85 # scenarios (typical manual tests) the file at a given url
86 # might get modified so avoid confusion by ensuring
87 # revalidations happens often.
88 proxy_cache_valid 200 10s;
89 proxy_cache_revalidate on;
90 include snippets/uri-caching.conf;
91 }
92 }