2019-02-27 05:39:38 -05:00
|
|
|
# this routing file is included in the hagrid http block
|
|
|
|
# it is assumed that hagrid runs on localhost:8080
|
|
|
|
|
2019-03-06 07:40:36 -05:00
|
|
|
# To protect against DOS, we limit the size of possible uploads.
|
|
|
|
client_max_body_size 1m;
|
2019-06-06 09:06:06 -04:00
|
|
|
client_body_buffer_size 128k;
|
2019-03-06 07:40:36 -05:00
|
|
|
|
2019-05-14 09:57:10 -04:00
|
|
|
# Change all HTTP 502 errors into 500, to avoid being "marked as dead" by GnuPG
|
|
|
|
# if we ever get a spurious 502 (e.g. during a restart of hagrid).
|
|
|
|
# See https://gitlab.com/sequoia-pgp/hagrid/issues/94
|
|
|
|
error_page 502 =500 /502;
|
|
|
|
location /502 {
|
|
|
|
return 500;
|
|
|
|
}
|
|
|
|
|
2019-05-14 12:52:28 -04:00
|
|
|
# for x-accel-redirect forwards
|
|
|
|
location /keys {
|
|
|
|
internal;
|
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
|
|
|
}
|
|
|
|
|
2019-06-15 08:01:14 -04:00
|
|
|
location /vks/v1/upload {
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /vks/v1/request-verify {
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-05-03 20:42:56 -04:00
|
|
|
location /vks/v1/ {
|
|
|
|
location ~ ^/vks/v1/by-email/([^/][^/])([^/][^/])([^/]*)$ {
|
2019-05-14 12:52:28 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
2019-06-15 08:02:30 -04:00
|
|
|
# we have some trouble with uri encoding here. just route through
|
|
|
|
# hagrid, for now.
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
# error_page 404 /errors/404-by-email.htm;
|
|
|
|
# default_type application/pgp-keys;
|
|
|
|
# add_header Content-Disposition 'attachment; filename="$1$2$3.asc"';
|
|
|
|
# try_files /keys/links/by-email/$1/$2/$3 =404;
|
2019-05-03 20:42:56 -04:00
|
|
|
}
|
2019-02-27 05:39:38 -05:00
|
|
|
|
2019-05-03 20:42:56 -04:00
|
|
|
location ~ ^/vks/v1/by-fingerprint/(?:0x)?([^/][^/])([^/][^/])(..*)$ {
|
2019-06-11 11:18:42 -04:00
|
|
|
error_page 404 /errors/404-by-fpr.htm;
|
2019-05-03 20:42:56 -04:00
|
|
|
default_type application/pgp-keys;
|
|
|
|
add_header Content-Disposition 'attachment; filename="$1$2$3.asc"';
|
2019-05-14 12:52:28 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
2019-06-11 11:18:42 -04:00
|
|
|
try_files /keys/links/by-fpr/$1/$2/$3 =404;
|
2019-05-03 20:42:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
location ~ ^/vks/v1/by-keyid/(?:0x)?([^/][^/])([^/][^/])(.*)$ {
|
2019-06-11 11:18:42 -04:00
|
|
|
error_page 404 /errors/404-by-keyid.htm;
|
2019-05-03 20:42:56 -04:00
|
|
|
default_type application/pgp-keys;
|
|
|
|
add_header Content-Disposition 'attachment; filename="$1$2$3.asc"';
|
2019-05-14 12:52:28 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
2019-06-11 11:18:42 -04:00
|
|
|
try_files /keys/links/by-keyid/$1/$2/$3 =404;
|
2019-05-03 20:42:56 -04:00
|
|
|
}
|
2019-02-27 05:39:38 -05:00
|
|
|
|
2019-05-14 12:52:28 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
2019-06-11 11:18:42 -04:00
|
|
|
error_page 400 /errors/400-vks-invalid.htm;
|
|
|
|
return 400;
|
2019-02-27 05:39:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# Common HKP requests.
|
|
|
|
location /pks/lookup {
|
|
|
|
# sq keyserver get <KEYID>, gpg --receive-keys <KEYID>
|
2019-05-03 20:42:56 -04:00
|
|
|
if ($args ~ "^op=get&options=mr&search=(?:0x)?([a-fA-F0-9]{16})$") {
|
2019-06-11 11:43:43 -04:00
|
|
|
set_by_lua $keyid "return ngx.arg[1]:upper()" $1;
|
2019-05-03 20:42:56 -04:00
|
|
|
set $args "";
|
|
|
|
rewrite . /vks/v1/by-keyid/$keyid last;
|
2019-02-27 05:39:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# gpg --receive-keys <FINGERPRINT>
|
2019-05-03 20:42:56 -04:00
|
|
|
if ($args ~ "^op=get&options=mr&search=(?:0x)?([a-fA-F0-9]{40})$") {
|
2019-06-11 11:43:43 -04:00
|
|
|
set_by_lua $fingerprint "return ngx.arg[1]:upper()" $1;
|
2019-05-03 20:42:56 -04:00
|
|
|
set $args "";
|
|
|
|
rewrite . /vks/v1/by-fingerprint/$fingerprint last;
|
2019-02-27 05:39:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# gpg --locate-key <EMAIL>
|
2019-05-03 20:42:56 -04:00
|
|
|
if ($request_uri ~ "^/pks/lookup\?op=get&options=mr&search=([^&]{3,}%40[^&]+)") {
|
2019-06-11 11:43:43 -04:00
|
|
|
set_by_lua $email "return ngx.arg[1]:lower()" $1;
|
2019-05-03 20:42:56 -04:00
|
|
|
set $args "";
|
|
|
|
rewrite . /vks/v1/by-email/$email last;
|
2019-02-27 05:39:38 -05:00
|
|
|
}
|
|
|
|
|
2019-06-10 11:30:13 -04:00
|
|
|
# gpg --search '<address@example.org>'
|
|
|
|
# strip angle brackets - we don't need them, but they cause issues
|
|
|
|
# with the Rocket framework
|
|
|
|
# see https://gitlab.com/sequoia-pgp/hagrid/issues/94
|
2019-07-01 13:28:42 -04:00
|
|
|
if ($request_uri ~ "^/pks/lookup\?(.*search=)[^&<>]*\<(.+)\>(.*)") {
|
2019-06-10 11:30:13 -04:00
|
|
|
set $left $1;
|
|
|
|
set $middle $2;
|
|
|
|
set $right $3;
|
|
|
|
set $args "";
|
|
|
|
rewrite . /pks/lookup?$left$middle$right? break;
|
|
|
|
}
|
|
|
|
|
2019-05-14 12:52:28 -04:00
|
|
|
# forward to backend, which will like serve via x-accel-redirect
|
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
2019-02-27 05:39:38 -05:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-04-28 16:41:41 -04:00
|
|
|
location /pks {
|
2019-03-06 06:30:37 -05:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-04-28 16:41:41 -04:00
|
|
|
location /manage {
|
2019-03-06 10:39:52 -05:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-05-23 19:01:24 -04:00
|
|
|
location /verify {
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-06-11 10:59:27 -04:00
|
|
|
location /search {
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-05-23 19:01:24 -04:00
|
|
|
location /upload {
|
2019-02-27 05:39:38 -05:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
2019-03-12 09:02:47 -04:00
|
|
|
|
2019-06-23 09:47:13 -04:00
|
|
|
location /debug {
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-04-28 16:41:41 -04:00
|
|
|
# explicitly cache the home directory
|
|
|
|
location = / {
|
|
|
|
proxy_cache static_cache;
|
2019-03-12 09:02:47 -04:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
2019-03-12 09:47:46 -04:00
|
|
|
|
2019-04-28 16:41:41 -04:00
|
|
|
# cache "about" pages
|
|
|
|
location /about {
|
|
|
|
proxy_cache static_cache;
|
2019-03-12 09:47:46 -04:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|