nginx: fix pks routes (again)

Fixes #142
This commit is contained in:
Vincent Breitmoser 2020-03-26 16:51:30 +01:00
parent f0aaee2a9d
commit 619f9f9554
No known key found for this signature in database
GPG Key ID: 7BD18320DEADFA11
1 changed files with 15 additions and 10 deletions

View File

@ -79,18 +79,23 @@ location /vks/v1/ {
# Common HKP requests.
location /pks/lookup {
# rewrite this to a path we can match on (right below)
if ($args ~ "op=.*search=") {
# urldecode the search parameter
set_by_lua $arg_search_decoded "return ngx.arg[1]:gsub(\"%%(%x%x)\", function(x) return string.char(tonumber(x, 16)) end)" $arg_search;
# if the search argument contains angle brackets, strip everything around them
set_by_lua $arg_search_decoded "return ngx.arg[1]:gsub(\"^.*<([^>]-)>.*$\", \"%1\")" $arg_search_decoded;
rewrite . /pks/internal/$arg_op/$arg_search_decoded last;
if ($arg_op !~ "^index|get$") {
add_header 'Access-Control-Allow-Origin' '*';
error_page 400 /errors-static/400-pks-invalid.htm;
return 400;
}
if ($arg_search = '') {
add_header 'Access-Control-Allow-Origin' '*';
error_page 400 /errors-static/400-pks-invalid.htm;
return 400;
}
add_header 'Access-Control-Allow-Origin' '*';
error_page 400 /errors-static/400-pks-invalid.htm;
return 400;
# rewrite this to a path we can match on (right below)
# urldecode the search parameter
set_by_lua $arg_search_decoded "return ngx.arg[1]:gsub(\"%%(%x%x)\", function(x) return string.char(tonumber(x, 16)) end)" $arg_search;
# if the search argument contains angle brackets, strip everything around them
set_by_lua $arg_search_decoded "return ngx.arg[1]:gsub(\"^.*<([^>]-)>.*$\", \"%1\")" $arg_search_decoded;
rewrite . /pks/internal/$arg_op/$arg_search_decoded last;
}
# WKD requests