95 lines
4.5 KiB
Nginx Configuration File
95 lines
4.5 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)(,[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 "";
|
|
'~^1,[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[|]1,' 1;
|
|
}
|
|
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"}';
|
|
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-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/(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_ack;
|
|
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; }
|
|
}
|
|
}
|