2018-10-25 11:38:49 -04:00
|
|
|
error_log stderr;
|
|
|
|
pid nginx/nginx.pid;
|
|
|
|
daemon off;
|
|
|
|
|
|
|
|
http {
|
2019-01-15 11:25:53 -05:00
|
|
|
# allow 6 requests per min -> one each 10s on avg.
|
|
|
|
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=6r/m;
|
|
|
|
|
2019-02-26 06:58:21 -05:00
|
|
|
proxy_cache_path /tmp/nginx_cache use_temp_path=off keys_zone=static_cache:10m;
|
|
|
|
proxy_cache_valid 200 5m;
|
|
|
|
|
2018-10-25 11:38:49 -04:00
|
|
|
server {
|
2019-02-26 07:13:37 -05:00
|
|
|
listen 0.0.0.0:8090;
|
2018-10-25 11:38:49 -04:00
|
|
|
|
|
|
|
access_log nginx/access_log;
|
|
|
|
|
2019-02-26 07:57:41 -05:00
|
|
|
# To debug the rewrite rules, enable these directives:
|
|
|
|
#error_log stderr notice;
|
|
|
|
#rewrite_log on;
|
|
|
|
|
2018-10-25 11:38:49 -04:00
|
|
|
include /etc/nginx/mime.types;
|
|
|
|
default_type application/octet-stream;
|
|
|
|
|
2018-11-02 06:48:02 -04:00
|
|
|
root dist/public;
|
2018-10-25 11:38:49 -04:00
|
|
|
|
2019-02-21 18:29:15 -05:00
|
|
|
location /by-email/ {
|
2019-02-22 17:45:41 -05:00
|
|
|
rewrite "^/by-email/([^/]{2})([^/]*)$" /by-email/$1/$2 break;
|
2018-10-25 11:38:49 -04:00
|
|
|
default_type application/pgp-keys;
|
2019-02-26 06:30:42 -05:00
|
|
|
add_header Content-Disposition 'attachment; filename="$1$2.asc"';
|
2019-02-21 18:29:15 -05:00
|
|
|
try_files /$uri =404;
|
2018-10-25 11:38:49 -04:00
|
|
|
}
|
|
|
|
|
2019-02-21 18:29:15 -05:00
|
|
|
location /by-fingerprint/ {
|
2019-02-26 07:56:47 -05:00
|
|
|
rewrite ^/by-fingerprint/(0x)?([^/][^/])(..*)$ /by-fingerprint/$2$3 break;
|
2018-11-02 06:48:02 -04:00
|
|
|
default_type application/pgp-keys;
|
2019-02-26 06:30:42 -05:00
|
|
|
add_header Content-Disposition 'attachment; filename="$2$3.asc"';
|
2019-02-26 07:56:47 -05:00
|
|
|
try_files /by-fpr/$2/$3 @fallback;
|
2018-11-02 06:48:02 -04:00
|
|
|
}
|
|
|
|
|
2019-02-21 18:29:15 -05:00
|
|
|
location /by-keyid/ {
|
2019-02-26 07:56:47 -05:00
|
|
|
rewrite ^/by-keyid/(0x)?([^/][^/])(.*)$ /by-keyid/$2$3 break;
|
2019-01-04 08:07:14 -05:00
|
|
|
default_type application/pgp-keys;
|
2019-02-26 06:30:42 -05:00
|
|
|
add_header Content-Disposition 'attachment; filename="$2$3.asc"';
|
2019-02-26 07:56:47 -05:00
|
|
|
try_files /by-keyid/$2/$3 @fallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Pass queries that we do not understand to hagrid.
|
|
|
|
location @fallback {
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
2019-01-04 08:07:14 -05:00
|
|
|
}
|
|
|
|
|
2019-02-22 17:45:41 -05:00
|
|
|
# Common HKP requests.
|
|
|
|
location /pks/lookup {
|
|
|
|
# sq keyserver get <KEYID>, gpg --receive-keys <KEYID>
|
2019-02-26 07:52:58 -05:00
|
|
|
if ($args ~ "^op=get&options=mr&?search=(0x)?([A-F0-9]{2})([A-F0-9]{14})$") {
|
2019-02-26 06:12:27 -05:00
|
|
|
set $dir $2;
|
|
|
|
set $file $3;
|
2019-02-22 17:45:41 -05:00
|
|
|
rewrite . /by-keyid/$dir/$file;
|
|
|
|
}
|
|
|
|
|
|
|
|
# gpg --receive-keys <FINGERPRINT>
|
2019-02-26 07:52:58 -05:00
|
|
|
if ($args ~ "^op=get&options=mr&?search=(0x)?([A-F0-9]{2})([A-F0-9]{38})$") {
|
2019-02-26 06:12:27 -05:00
|
|
|
set $dir $2;
|
|
|
|
set $file $3;
|
2019-02-22 17:45:41 -05:00
|
|
|
rewrite . /by-fingerprint/$dir/$file;
|
|
|
|
}
|
|
|
|
|
|
|
|
# gpg --locate-key <EMAIL>
|
2019-02-26 07:52:58 -05:00
|
|
|
if ($args ~ "^op=get&options=mr&?search=(..)([^&]*)(@|%40)([^&]*)") {
|
2019-02-26 06:12:27 -05:00
|
|
|
set $dir $1;
|
|
|
|
set $local $2;
|
2019-02-26 06:29:44 -05:00
|
|
|
set $horst $4;
|
2019-02-22 17:45:41 -05:00
|
|
|
rewrite . /by-email/$dir/$local%40$horst;
|
|
|
|
}
|
2019-02-26 06:12:27 -05:00
|
|
|
|
|
|
|
proxy_pass http://127.0.0.1:8080;
|
2019-02-22 17:45:41 -05:00
|
|
|
}
|
|
|
|
|
2018-11-02 06:48:02 -04:00
|
|
|
location = / {
|
2019-02-26 06:58:21 -05:00
|
|
|
proxy_cache static_cache;
|
2018-11-02 06:48:02 -04:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-02-26 06:33:44 -05:00
|
|
|
location = /about {
|
2019-02-26 06:58:21 -05:00
|
|
|
proxy_cache static_cache;
|
2019-02-26 06:33:44 -05:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
|
|
|
|
2019-02-26 08:32:11 -05:00
|
|
|
location /vks/ {
|
2018-11-02 06:48:02 -04:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
|
|
|
}
|
2018-10-25 11:38:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
events {
|
|
|
|
worker_connections 4096;
|
|
|
|
}
|