Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion conf/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ http {
# Directory listings (trailing slash) always go to /download/.
# $builds_backend is set by the map directive in the http block above.
#
rewrite ^/builds/([^/]+/.+[^/])$ $builds_backend$1 last;
if ($builds_backend = /redirect/) {
rewrite ^/builds/([^/]+/.+[^/])$ /redirect/$1 last;
}
rewrite ^/builds/(.*)$ /download/$1 last;

# Handle subdir listing under "/redirect/"
Expand Down
9 changes: 7 additions & 2 deletions tests/end2end/test_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,19 @@ def test_builds_cli_ua_redirects_to_presigned_url(upload_file, session, artifact


def test_builds_browser_ua_proxied_directly(upload_file, session, artifacts_url):
"""GET /builds/ with a Mozilla UA is rewritten to /download/ → 200 proxied."""
upload_file(STAGING_BUILD, 'file.txt')
"""GET /builds/ with a Mozilla UA is rewritten to /download/ → 200 proxied.

The response body must be the file content, not an HTML directory listing.
"""
data = b'browser-proxied content'
upload_file(STAGING_BUILD, 'file.txt', data=data)
resp = session.get(
f'{artifacts_url}/builds/{STAGING_BUILD}/file.txt',
headers={'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64)'},
allow_redirects=False,
)
assert resp.status_code == 200
assert resp.content == data


def test_builds_head_always_proxied_regardless_of_ua(upload_file, session, artifacts_url):
Expand Down
Loading