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

View File

@@ -79,8 +79,18 @@ location /vks/v1/ {
# Common HKP requests. # Common HKP requests.
location /pks/lookup { location /pks/lookup {
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;
}
# rewrite this to a path we can match on (right below) # rewrite this to a path we can match on (right below)
if ($args ~ "op=.*search=") {
# urldecode the search parameter # 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; 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 # if the search argument contains angle brackets, strip everything around them
@@ -88,11 +98,6 @@ location /pks/lookup {
rewrite . /pks/internal/$arg_op/$arg_search_decoded last; rewrite . /pks/internal/$arg_op/$arg_search_decoded last;
} }
add_header 'Access-Control-Allow-Origin' '*';
error_page 400 /errors-static/400-pks-invalid.htm;
return 400;
}
# WKD requests # WKD requests
location /.well-known/openpgpkey { location /.well-known/openpgpkey {
etag off; etag off;