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-07-11 18:50:10 -04:00
|
|
|
limit_req_status 429;
|
|
|
|
|
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;
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
|
|
|
etag off;
|
2019-05-14 12:52:28 -04:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-09-07 04:50:57 -04:00
|
|
|
location /vks {
|
2019-05-03 20:42:56 -04:00
|
|
|
location ~ ^/vks/v1/by-fingerprint/(?:0x)?([^/][^/])([^/][^/])(..*)$ {
|
2021-06-11 05:25:27 -04:00
|
|
|
limit_req zone=search_fpr_keyid burst=1000 nodelay;
|
2019-07-11 16:59:18 -04:00
|
|
|
|
|
|
|
error_page 404 /errors-static/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"';
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
etag off;
|
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)?([^/][^/])([^/][^/])(.*)$ {
|
2021-06-11 05:25:27 -04:00
|
|
|
limit_req zone=search_fpr_keyid burst=1000 nodelay;
|
2019-07-11 18:50:10 -04:00
|
|
|
error_page 429 /errors-static/429-rate-limit-vks-fpr.htm;
|
2019-07-11 16:59:18 -04:00
|
|
|
|
|
|
|
error_page 404 /errors-static/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"';
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
etag off;
|
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-07-11 16:59:18 -04:00
|
|
|
location /vks/v1/by-email/ {
|
|
|
|
limit_req zone=search_email burst=50 nodelay;
|
2021-03-05 07:23:51 -05:00
|
|
|
limit_req zone=search_email_loose burst=200 nodelay;
|
2019-07-11 18:50:10 -04:00
|
|
|
error_page 429 /errors-static/429-rate-limit-vks-email.htm;
|
2019-07-11 16:59:18 -04:00
|
|
|
|
2019-07-12 06:23:16 -04:00
|
|
|
set $args "";
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
etag off;
|
2019-07-12 06:23:16 -04:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
|
2019-07-11 16:59:18 -04:00
|
|
|
# we have some trouble with uri encoding here. just route through
|
|
|
|
# hagrid, for now.
|
|
|
|
# error_page 404 /errors-static/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;
|
|
|
|
}
|
|
|
|
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
|
|
|
etag off;
|
2019-07-11 16:59:18 -04:00
|
|
|
error_page 400 /errors-static/400-vks-invalid.htm;
|
2019-06-11 11:18:42 -04:00
|
|
|
return 400;
|
2019-02-27 05:39:38 -05:00
|
|
|
}
|
|
|
|
|
2019-07-12 06:23:16 -04:00
|
|
|
# Common HKP requests.
|
|
|
|
location /pks/lookup {
|
2020-03-26 11:51:30 -04:00
|
|
|
if ($arg_op !~ "^index|get$") {
|
|
|
|
error_page 400 /errors-static/400-pks-invalid.htm;
|
|
|
|
return 400;
|
|
|
|
}
|
|
|
|
if ($arg_search = '') {
|
|
|
|
error_page 400 /errors-static/400-pks-invalid.htm;
|
|
|
|
return 400;
|
2019-07-12 06:23:16 -04:00
|
|
|
}
|
2019-07-11 18:50:10 -04:00
|
|
|
|
2020-03-26 11:51:30 -04:00
|
|
|
# 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;
|
2019-07-11 17:44:56 -04:00
|
|
|
}
|
|
|
|
|
2020-01-31 06:35:58 -05:00
|
|
|
# WKD requests
|
|
|
|
location /.well-known/openpgpkey {
|
|
|
|
location ~ "^/.well-known/openpgpkey/([^/]+)/hu/([^/][^/])([^/][^/])(.*)" {
|
|
|
|
limit_req zone=search_email burst=50 nodelay;
|
2021-03-05 07:23:51 -05:00
|
|
|
limit_req zone=search_email_loose burst=200 nodelay;
|
2020-01-31 06:35:58 -05:00
|
|
|
error_page 429 /errors-static/429-rate-limit-vks-email.htm;
|
|
|
|
|
|
|
|
error_page 404 /errors-static/404-wkd.htm;
|
2021-04-28 07:22:37 -04:00
|
|
|
default_type application/octet-stream;
|
2020-01-31 06:35:58 -05:00
|
|
|
add_header Content-Disposition 'attachment; filename="$2$3$4.asc"';
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
etag off;
|
2020-01-31 06:35:58 -05:00
|
|
|
try_files /keys/links/wkd/$1/$2/$3/$4 =404;
|
|
|
|
}
|
|
|
|
|
2020-02-05 08:23:09 -05:00
|
|
|
location ~ "^/.well-known/openpgpkey/([^/]+)/policy$" {
|
2020-01-31 06:35:58 -05:00
|
|
|
default_type text/plain;
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
etag off;
|
2020-01-31 06:35:58 -05:00
|
|
|
return 200 '';
|
|
|
|
}
|
|
|
|
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
|
|
|
etag off;
|
2020-01-31 06:35:58 -05:00
|
|
|
error_page 400 /errors-static/400-wkd-invalid.htm;
|
|
|
|
return 400;
|
|
|
|
}
|
|
|
|
|
2019-07-12 06:23:16 -04:00
|
|
|
location /pks/internal {
|
|
|
|
internal;
|
|
|
|
|
2019-07-11 16:59:18 -04:00
|
|
|
# search by key id
|
2019-02-27 05:39:38 -05:00
|
|
|
# sq keyserver get <KEYID>, gpg --receive-keys <KEYID>
|
2019-07-12 06:23:16 -04:00
|
|
|
location ~ "^/pks/internal/get/(?: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
|
|
|
rewrite . /vks/v1/by-keyid/$keyid last;
|
2019-02-27 05:39:38 -05:00
|
|
|
}
|
|
|
|
|
2019-07-11 16:59:18 -04:00
|
|
|
# search by fpr
|
2019-02-27 05:39:38 -05:00
|
|
|
# gpg --receive-keys <FINGERPRINT>
|
2019-07-12 06:23:16 -04:00
|
|
|
location ~ "^/pks/internal/get/(?: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
|
|
|
rewrite . /vks/v1/by-fingerprint/$fingerprint last;
|
2019-02-27 05:39:38 -05:00
|
|
|
}
|
|
|
|
|
2019-07-11 16:59:18 -04:00
|
|
|
# search by email
|
2019-02-27 05:39:38 -05:00
|
|
|
# gpg --locate-key <EMAIL>
|
2019-07-12 06:23:16 -04:00
|
|
|
location ~ "^/pks/internal/get/(.+(?:%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
|
|
|
rewrite . /vks/v1/by-email/$email last;
|
2019-02-27 05:39:38 -05:00
|
|
|
}
|
|
|
|
|
2019-07-12 06:23:16 -04:00
|
|
|
# index by fingerprint
|
|
|
|
# gpg --search-keys <FINGEPRINT>
|
|
|
|
location ~ "^/pks/internal/index/(?:0x)?([a-fA-F0-9]{40})$" {
|
2021-06-11 05:25:27 -04:00
|
|
|
limit_req zone=search_fpr_keyid burst=1000 nodelay;
|
2019-07-12 06:23:16 -04:00
|
|
|
limit_req_status 429;
|
|
|
|
error_page 429 /errors-static/429-rate-limit-pks-index.htm;
|
|
|
|
|
|
|
|
set $args "";
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
|
|
|
etag off;
|
2019-07-12 06:23:16 -04:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
|
|
|
# index by keyid
|
|
|
|
# gpg --search-keys <KEYID>
|
|
|
|
location ~ "^/pks/internal/index/(?:0x)?([a-fA-F0-9]{16})$" {
|
2021-06-11 05:25:27 -04:00
|
|
|
limit_req zone=search_fpr_keyid burst=1000 nodelay;
|
2019-07-12 06:23:16 -04:00
|
|
|
limit_req_status 429;
|
|
|
|
error_page 429 /errors-static/429-rate-limit-pks-index.htm;
|
|
|
|
|
2019-07-11 17:44:56 -04:00
|
|
|
set $args "";
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
|
|
|
etag off;
|
2019-07-12 06:23:16 -04:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
2019-07-11 17:44:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# index by email
|
|
|
|
# gpg --search-keys <QUERY>
|
2019-07-12 06:23:16 -04:00
|
|
|
location ~ ^/pks/internal/index/(.+(?:%40|@).+)$ {
|
|
|
|
limit_req zone=search_email burst=50 nodelay;
|
2021-03-05 07:23:51 -05:00
|
|
|
limit_req zone=search_email_loose burst=200 nodelay;
|
2019-07-12 06:23:16 -04:00
|
|
|
limit_req_status 429;
|
|
|
|
error_page 429 /errors-static/429-rate-limit-pks-index.htm;
|
|
|
|
|
2019-07-11 17:44:56 -04:00
|
|
|
set $args "";
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
|
|
|
etag off;
|
2019-07-12 06:23:16 -04:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
2019-07-11 17:44:56 -04:00
|
|
|
}
|
|
|
|
|
2020-05-04 13:39:25 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
2020-05-07 17:13:47 -04:00
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
|
|
|
etag off;
|
2019-07-11 16:59:18 -04:00
|
|
|
error_page 400 /errors-static/400-pks-invalid.htm;
|
|
|
|
return 400;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /errors-static {
|
|
|
|
internal;
|
2020-05-07 17:13:47 -04:00
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
|
|
add_header 'Cache-Control' 'no-cache' always;
|
|
|
|
etag off;
|
2019-02-27 05:39:38 -05:00
|
|
|
}
|
|
|
|
|
2019-07-11 16:38:16 -04:00
|
|
|
location /errors {
|
|
|
|
internal;
|
2019-03-06 06:30:37 -05:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
2019-07-11 16:59:18 -04:00
|
|
|
proxy_cache static_cache;
|
2019-03-06 06:30:37 -05:00
|
|
|
}
|
|
|
|
|
2019-07-11 16:38:16 -04:00
|
|
|
location /search {
|
2019-07-11 16:59:18 -04:00
|
|
|
limit_req zone=search_email burst=50 nodelay;
|
2021-03-05 07:23:51 -05:00
|
|
|
limit_req zone=search_email_loose burst=200 nodelay;
|
2019-07-11 18:50:10 -04:00
|
|
|
error_page 429 /errors/429/rate-limit-web;
|
2019-03-06 10:39:52 -05:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-07-11 16:38:16 -04:00
|
|
|
location /pks {
|
2019-05-23 19:01:24 -04:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-07-11 16:38:16 -04:00
|
|
|
location /manage {
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /verify {
|
2019-06-11 10:59:27 -04:00
|
|
|
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-10-04 09:02:01 -04:00
|
|
|
# cache "about" pages
|
|
|
|
location = /atom.xml {
|
|
|
|
proxy_cache static_cache;
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|