jenkins d2f4e920ff bstein: serve direct-duration digital RCT reference runs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 14:08:00 -06:00

108 lines
5.0 KiB
Nginx Configuration File

worker_processes 1;
pid /tmp/nginx.pid;
error_log /dev/stderr warn;
events { worker_connections 128; }
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log off;
# The receipt service authenticates the body and sequence. Log only the
# numeric stage annotation of an accepted report, correlated by that body.
map $request_body $av_identity {
default "";
'~^[{]"run_id":"(?<av_id>[0-9a-f]{32})","sequence":(?<av_sequence>[1-9][0-9]?),"state":"(?<av_state>running|completed|failed|hidden|closed|stopped|device-change)",' "$av_id/$av_sequence/$av_state";
}
map $http_x_av_stage $av_annotation {
default "";
'~^(1|5|10|15|20|30|60)(,[0-9]{1,7}){6},(0|[0-9]{13}),[0-9]{1,5}(,-?[0-9]{1,7}){7}$' $http_x_av_stage;
}
map "$uri|$upstream_status|$av_identity|$av_annotation" $av_ack {
default "";
'~^/av-test/api/report[|]204[|][^|]+[|][-0-9,]+$' 1;
}
map $http_x_av_speech $av_speech {
default "";
'~^[12],[0-9]{1,7},-?[0-9]{1,4},-?[0-9]{1,7},[0-9]{1,6},-?[0-9]{1,7}(;[0-9]{1,6},[1-4],[0-9]{1,7},[0-9]{1,7},-?[0-9]{1,7},-?[0-9]{1,4}){0,16}$' $http_x_av_speech;
}
map "$av_ack|$av_speech" $av_speech_ack {
default "";
'~^1[|][12],' 1;
}
map $http_x_av_watch $av_watch {
default "";
'~^1(,-?[0-9]{1,13}){31}(;[0-9]{1,6},[0-9]{1,2},[0-9]{13}){0,16}$' $http_x_av_watch;
}
map "$uri|$upstream_status|$av_identity|$av_watch" $av_watch_ack {
default "";
'~^/av-test/api/report[|]204[|][^|]+[|]1,' 1;
}
map "$av_ack$av_watch_ack" $av_log {
default 1;
"" 0;
}
map "$uri|$upstream_status" $av_clock {
default "";
"/av-test/api/start|201" $msec;
}
log_format av_stage escape=json '{"schema":"av-test.acoustic-stage.v1","received":"$msec","receipt":"$av_identity","stage":"$av_annotation","speech":"$av_speech","watch":"$av_watch"}';
server_tokens off;
client_max_body_size 4k;
client_body_timeout 5s;
client_header_timeout 5s;
client_body_temp_path /tmp/client;
proxy_temp_path /tmp/proxy;
fastcgi_temp_path /tmp/fastcgi;
uwsgi_temp_path /tmp/uwsgi;
scgi_temp_path /tmp/scgi;
server {
listen 8080;
absolute_redirect off;
root /usr/share/nginx/html;
add_header X-AV-Clock $av_clock always;
add_header X-AV-Speech-Ack $av_speech_ack always;
add_header X-AV-Watch-Ack $av_watch_ack always;
add_header X-AV-Stage-Ack $av_ack always;
add_header Cache-Control "no-store" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header Referrer-Policy "no-referrer" always;
add_header Permissions-Policy "camera=(self), microphone=(self), speaker-selection=(self), geolocation=(), display-capture=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header Content-Security-Policy "default-src 'none'; script-src 'self'; style-src 'self'; media-src 'self' blob:; connect-src 'self'; worker-src 'self'; object-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'" always;
location = /lesavka-av-test { return 308 /av-test/; }
location = /lesavka-av-test/ { return 308 /av-test/; }
location = /lesavka-av-test/index.html { return 308 /av-test/; }
# Kubelet checks the running listener without spawning Python each time.
# This path is outside the observer's public ingress prefixes.
location = /healthz {
proxy_pass http://127.0.0.1:8081/healthz;
proxy_connect_timeout 2s;
proxy_read_timeout 2s;
proxy_pass_request_headers off;
}
location = /av-test { return 308 /av-test/; }
location = /av-test/ {
if ($request_method !~ ^(GET|HEAD)$) { return 405; }
try_files /av-test/index.html =404;
}
location ~ ^/av-test/(mic-entry\.js|mic-watch\.js|watch-worklet\.js|speech-reference\.flac|speech-alignment\.js|speech-detector\.js|speech-envelope\.js|speech-watch\.js|speech-worklet\.js|acoustic-detector\.js|acoustic-pattern\.js|acoustic-watch\.js|acoustic-worklet\.js|acoustic-timing\.js|phone-source\.js|phone\.html|mic\.html|mic-observer\.js|mic-reporting\.js|mic-output\.js|index\.html|observer\.js|local-recording\.js|review-controls\.js|metrics\.js|reporting\.js|activity-worklet\.js|paired-observer\.js|paired-worklet\.js|paired-signals\.js|test-signals\.js|continuity-signals\.js|pilot-window\.js|capture-lifecycle\.js|continuity-watch\.js|style\.css)$ {
if ($request_method !~ ^(GET|HEAD)$) { return 405; }
try_files $uri =404;
}
location ~ ^/av-test/api/(start|report)$ {
access_log /dev/stdout av_stage if=$av_log;
if ($request_method != POST) { return 405; }
proxy_pass http://127.0.0.1:8081;
proxy_connect_timeout 2s;
proxy_read_timeout 5s;
proxy_send_timeout 5s;
proxy_pass_request_headers off;
proxy_set_header Content-Type $http_content_type;
proxy_set_header Origin $http_origin;
proxy_set_header Authorization $http_authorization;
proxy_set_header Host localhost;
}
location / { return 404; }
}
}