feat(deploy): restrict the public perimeter and resolve the client address
This commit is contained in:
1 parent
e52ffe7bcb
commit
57174dffba
25 files changed
+1224
-25
No files matched your search
+39
-2
@@ -18,7 +18,15 @@ http {
|
||||
tcp_nopush on;
|
||||
keepalive_timeout 30s;
|
||||
server_tokens off;
|
||||
client_max_body_size 10m;
|
||||
# Default request body limit: the JSON API bodies of the contract are
|
||||
# small. The 5 MB resume upload has no operation in the contract yet; the
|
||||
# route that gets one raises the limit in its own location in app.conf.
|
||||
# The edge proxy allows 10 MB (EDGE_MAX_BODY) and must stay at or above
|
||||
# the largest limit here.
|
||||
client_max_body_size 1m;
|
||||
client_header_timeout 10s;
|
||||
client_body_timeout 30s;
|
||||
send_timeout 30s;
|
||||
|
||||
client_body_temp_path /tmp/client_body;
|
||||
proxy_temp_path /tmp/proxy;
|
||||
@@ -26,7 +34,36 @@ http {
|
||||
scgi_temp_path /tmp/scgi;
|
||||
uwsgi_temp_path /tmp/uwsgi;
|
||||
|
||||
limit_req_zone $binary_remote_addr zone=telemetry_rate:10m rate=30r/m;
|
||||
# Coarse per-client protection only. $remote_addr is the client address
|
||||
# that app.conf resolved through the trusted edge (realip), never a value
|
||||
# the client supplied. The values are far above normal browsing: the
|
||||
# per-account and per-route quotas stay in the backend and are not
|
||||
# replaced by these. The zones keep addresses in memory only; the access
|
||||
# log does not record them.
|
||||
#
|
||||
# The key is the address, except that an IPv6 address counts as its /64
|
||||
# network (as middleware.LimiterKey does in the backend): one subscriber
|
||||
# controls a whole /64 and could otherwise take a new bucket per request.
|
||||
# $remote_addr is canonical text here (inet_ntop from the edge), so the
|
||||
# first four groups, or the part before "::", name the network. The two
|
||||
# spellings of one /64 that differ in where "::" falls get two buckets, a
|
||||
# harmless looseness for a coarse limit.
|
||||
map $remote_addr $limit_key {
|
||||
"~^(?<v6full>(?:[0-9a-f]{1,4}:){4})" $v6full;
|
||||
"~^(?<v6short>(?:[0-9a-f]{1,4}(?::[0-9a-f]{1,4}){0,2})?::)" $v6short;
|
||||
default $remote_addr;
|
||||
}
|
||||
limit_req_zone $limit_key zone=api_rate:10m rate=20r/s;
|
||||
limit_conn_zone $limit_key zone=api_conn:10m;
|
||||
limit_req_zone $limit_key zone=telemetry_rate:10m rate=30r/m;
|
||||
limit_req_status 429;
|
||||
limit_conn_status 429;
|
||||
# A rejection line in the error log names the client address. Rejections
|
||||
# are routine under a flood and the address must not be logged, so they
|
||||
# are logged at notice, below the warn threshold of error_log above
|
||||
# (the default, error, would write them with the address).
|
||||
limit_req_log_level notice;
|
||||
limit_conn_log_level notice;
|
||||
resolver 127.0.0.11 valid=30s ipv6=off;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
Reference in new issue
Block a user