Handle common HKP queries using nginx.

- Fixes #46.
This commit is contained in:
Justus Winter 2019-02-22 23:45:41 +01:00
parent 13ea83b10d
commit 7b5eb8968c
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
1 changed files with 26 additions and 1 deletions

View File

@ -17,7 +17,7 @@ http {
root dist/public;
location /by-email/ {
rewrite ^/by-email/([^/][^/])(..*)$ /by-email/$1/$2 break;
rewrite "^/by-email/([^/]{2})([^/]*)$" /by-email/$1/$2 break;
default_type application/pgp-keys;
try_files /$uri =404;
}
@ -34,6 +34,31 @@ http {
try_files /$uri =404;
}
# Common HKP requests.
location /pks/lookup {
# sq keyserver get <KEYID>, gpg --receive-keys <KEYID>
if ($args ~* "^op=get&options=mr&search=0x([A-F0-9]{2})([A-F0-9]{14})$") {
set $dir $1;
set $file $2;
rewrite . /by-keyid/$dir/$file;
}
# gpg --receive-keys <FINGERPRINT>
if ($args ~* "^op=get&options=mr&search=0x([A-F0-9]{2})([A-F0-9]{38})$") {
set $dir $1;
set $file $2;
rewrite . /by-fingerprint/$dir/$file;
}
# gpg --locate-key <EMAIL>
if ($args ~* "^op=get&options=mr&search=(..)([^&]*)@([^&]*)") {
set $dir $1;
set $local $2;
set $horst $3;
rewrite . /by-email/$dir/$local%40$horst;
}
}
location = / {
proxy_pass http://127.0.0.1:8080;
}