hagrid-keyserver--hagrid/hagrid-routes.conf

83 lines
2.2 KiB
Plaintext

# this routing file is included in the hagrid http block
# it is assumed that hagrid runs on localhost:8080
# To protect against DOS, we limit the size of possible uploads.
client_max_body_size 1m;
location /vks/v1/ {
location ~ ^/vks/v1/by-email/([^/][^/])([^/][^/])([^/]*)$ {
default_type application/pgp-keys;
add_header Content-Disposition 'attachment; filename="$1$2$3.asc"';
try_files /keys/by-email/$1/$2/$3 @fallback;
}
location ~ ^/vks/v1/by-fingerprint/(?:0x)?([^/][^/])([^/][^/])(..*)$ {
default_type application/pgp-keys;
add_header Content-Disposition 'attachment; filename="$1$2$3.asc"';
try_files /keys/by-fpr/$1/$2/$3 @fallback;
}
location ~ ^/vks/v1/by-keyid/(?:0x)?([^/][^/])([^/][^/])(.*)$ {
default_type application/pgp-keys;
add_header Content-Disposition 'attachment; filename="$1$2$3.asc"';
try_files /keys/by-keyid/$1/$2/$3 @fallback;
}
proxy_pass http://127.0.0.1:8080;
}
# Pass queries that we do not understand to hagrid.
location @fallback {
proxy_pass http://127.0.0.1:8080;
}
# Common HKP requests.
location /pks/lookup {
# sq keyserver get <KEYID>, gpg --receive-keys <KEYID>
if ($args ~ "^op=get&options=mr&search=(?:0x)?([a-fA-F0-9]{16})$") {
set $keyid $1;
set $args "";
rewrite . /vks/v1/by-keyid/$keyid last;
}
# gpg --receive-keys <FINGERPRINT>
if ($args ~ "^op=get&options=mr&search=(?:0x)?([a-fA-F0-9]{40})$") {
set $fingerprint $1;
set $args "";
rewrite . /vks/v1/by-fingerprint/$fingerprint last;
}
# gpg --locate-key <EMAIL>
if ($request_uri ~ "^/pks/lookup\?op=get&options=mr&search=([^&]{3,}%40[^&]+)") {
set $email $1;
set $args "";
rewrite . /vks/v1/by-email/$email last;
}
proxy_pass http://127.0.0.1:8080;
}
location /pks {
proxy_pass http://127.0.0.1:8080;
}
location /manage {
proxy_pass http://127.0.0.1:8080;
}
location /publish {
proxy_pass http://127.0.0.1:8080;
}
# explicitly cache the home directory
location = / {
proxy_cache static_cache;
proxy_pass http://127.0.0.1:8080;
}
# cache "about" pages
location /about {
proxy_cache static_cache;
proxy_pass http://127.0.0.1:8080;
}