Skip to content

Commit feaaec0

Browse files
Use redirect instead of download to use s3
1 parent b93809e commit feaaec0

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
@@ -251,7 +251,21 @@ http {
251251

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

257271
# Handle subdir listing under "/redirect/"

0 commit comments

Comments
 (0)