File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff 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/"
You can’t perform that action at this time.
0 commit comments