Skip to content

Commit dabbb54

Browse files
Use redirect instead of download to use s3
1 parent 7f66404 commit dabbb54

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

conf/nginx.conf.template

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,21 @@ http {
246246

247247
# Handle "/builds/" location to keep backward compatibility with the
248248
# previous artifacts implementations.
249-
#
249+
# CLI clients (curl, wget, aria2c — no "Mozilla" in User-Agent) fetching
250+
# a file are internally rewritten to /redirect/ so they receive a presigned
251+
# URL and download directly from S3. Browser clients keep the original
252+
# proxied-through-nginx behaviour (/download/).
253+
# Directory listings (trailing slash) always go to /download/.
254+
#
255+
set $builds_backend "/download/";
256+
if ($http_user_agent !~* "Mozilla") {
257+
set $builds_backend "/redirect/";
258+
}
259+
# HEAD requests are metadata checks, not downloads: always proxy directly.
260+
if ($request_method = "HEAD") {
261+
set $builds_backend "/download/";
262+
}
263+
rewrite ^/builds/([^/]+/.+[^/])$ $builds_backend$1 last;
250264
rewrite ^/builds/(.*)$ /download/$1 last;
251265

252266
# Handle subdir listing under "/redirect/"

0 commit comments

Comments
 (0)