include /etc/jitsi/meet/jaas/jaas-vars;
location = /jaas-jwt {
  include /etc/jitsi/token-generator/daily-key;
  ssi on;
  proxy_method POST;
  proxy_set_header content-type "application/json";
  proxy_set_header Accept-Encoding "";
  proxy_set_header Authorization "Bearer $jaas_asap_key";
  proxy_pass_request_body off;
  proxy_set_body '{"sub":"jaas_magic_cookie","context":{"features":{"livestreaming":false,"outbound-call":false,"sip-outbound-call":false,"transcription":false,"recording":false},"user":{"moderator":true}},"room": "$roomname"}';
  proxy_pass http://127.0.0.1:8017/generate/client?e2eeKey=true&confId=true;
}

location @magic_root_path {
    rewrite ^/(.*)$ /index.html break;
}

# Anything that didn't match above, and isn't a real file, assume it's a room name and redirect to /
location ~ ^/jaas_magic_cookie/(.*)$ {
    set $subdomain "jaas_magic_cookie.";
    set $subdir "jaas_magic_cookie/";
    try_files $1 @magic_root_path;
}
