Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion ansible/roles/ooni-backend/templates/rotation_nginx_conf
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
# Managed by ansible, see roles/ooni-backend/tasks/main.yml
# and roles/ooni-backend/templates/rotation_nginx_conf
# Deployed by rotation tool to the test-helper hosts

# Use 2-level cache using 5GB on disk
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=thcache:100M
max_size=5g inactive=24h use_temp_path=off;

# anonymize ipaddr
map $remote_addr $remote_addr_anon {
~(?P<ip>\d+\.\d+\.\d+)\. $ip.0;
~(?P<ip>[^:]+:[^:]+): $ip::;
default 0.0.0.0;
}

# anonymize forwarded ipaddr
map $http_x_forwarded_for $remote_fwd_anon {
~(?P<ip>\d+\.\d+\.\d+)\. $ip.0;
~(?P<ip>[^:]+:[^:]+): $ip::;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://stackoverflow.com/questions/6098517/anonymizing-ipv6-addresses for a conversation about how much one should strip of IPv6 addresses to make sense of them. So far, we're erring on the stripping more side but we may want to revisit this choice at a later time if stripping too much makes it impossible to make sense of IPv6 addresses in the logs (I am thinking, in particular, about attacks to mitigate).

default 0.0.0.0;
}

# log anonymized ipaddr and caching status
log_format ooni_log_fmt '$remote_addr_anon $remote_fwd_anon $upstream_cache_status [$time_local] '
'"$request" $status snt:$body_bytes_sent rt:$request_time uprt:$upstream_response_time "$http_referer" "$http_user_agent"';

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name _;
access_log syslog:server=unix:/dev/log,tag=nginx,severity=info ooni_log_fmt;
error_log syslog:server=unix:/dev/log,tag=nginx,severity=info;

gzip on;
ssl_certificate /etc/ssl/private/th_fullchain.pem;
ssl_certificate_key /etc/ssl/private/th_privkey.pem;
Expand All @@ -20,7 +43,10 @@ server {
add_header Strict-Transport-Security "max-age=63072000" always;
ssl_stapling on;
ssl_stapling_verify on;
resolver 127.0.0.1;

# No local caching resolver configured. Use external resolvers by default.
# resolver 127.0.0.1;

# local test helper
location / {
proxy_set_header X-Forwarded-Proto $scheme;
Expand Down