mirror of
https://gitlab.archlinux.org/archlinux/infrastructure.git
synced 2026-11-29 18:25:17 +01:00
145 lines
4.3 KiB
Django/Jinja
145 lines
4.3 KiB
Django/Jinja
uwsgi_cache_path /var/lib/nginx/cache/mailman levels=1:2 keys_zone=mailmancache:10m inactive=60m max_size=512m;
|
|
|
|
# limit general requests to 2 r/s to block DoS attempts.
|
|
limit_req_zone $binary_remote_addr zone=mailmanlimit:10m rate=2r/s;
|
|
|
|
# Throttle the heavy search endpoint harder than the rest.
|
|
limit_req_zone $binary_remote_addr zone=mailmansearch:10m rate=20r/m;
|
|
|
|
limit_req_status 429;
|
|
|
|
# Global concurrency for uwsgi backend which runs 10 worker processes
|
|
map $host $mailman_conn_key {
|
|
default "global";
|
|
}
|
|
limit_conn_zone $mailman_conn_key zone=mailmanconn:10m;
|
|
|
|
# Drop various aggressive AI/scraper bots.
|
|
map $http_user_agent $mailman_blocked_ua {
|
|
default 0;
|
|
"~*Bytespider" 1;
|
|
"~*GPTBot" 1;
|
|
"~*ClaudeBot" 1;
|
|
"~*Amazonbot" 1;
|
|
"~*AhrefsBot" 1;
|
|
"~*SemrushBot" 1;
|
|
"~*meta-externalagent" 1;
|
|
"~*DataForSeoBot" 1;
|
|
"~*DotBot" 1;
|
|
"~*Sogou" 1;
|
|
"~*PetalBot" 1;
|
|
"~*MJ12bot" 1;
|
|
}
|
|
|
|
# This is for POSTORIUS_TEMPLATE_BASE_URL and mailman_hyperkitty.Archiver's base_url.
|
|
server {
|
|
listen 8000;
|
|
listen [::]:8000;
|
|
server_name localhost;
|
|
|
|
access_log off;
|
|
|
|
location / {
|
|
include /etc/nginx/uwsgi_params;
|
|
uwsgi_pass unix:/run/mailman-web/mailman-web.sock;
|
|
}
|
|
}
|
|
|
|
include snippets/redirect-80.conf;
|
|
|
|
server {
|
|
include snippets/listen-443.conf;
|
|
server_name {{ lists_domain }};
|
|
|
|
access_log off;
|
|
error_log /dev/null;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/{{ lists_domain }}/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/{{ lists_domain }}/privkey.pem;
|
|
|
|
location / {
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Http-Version $server_protocol;
|
|
proxy_redirect http://{{ lists_domain }}:3000/ /;
|
|
# Anubis
|
|
proxy_pass http://127.0.0.1:8923;
|
|
# Bypass Anubis
|
|
# proxy_pass http://127.0.0.1:3000;
|
|
}
|
|
}
|
|
|
|
server {
|
|
set_real_ip_from 127.0.0.1;
|
|
real_ip_header X-Real-IP;
|
|
listen 127.0.0.1:3000;
|
|
|
|
access_log /var/log/nginx/{{ lists_domain }}/access.log main;
|
|
access_log /var/log/nginx/{{ lists_domain }}/access.log.json json_main;
|
|
error_log /var/log/nginx/{{ lists_domain }}/error.log;
|
|
|
|
# Bytespider's distributed AWS range.
|
|
deny 47.128.59.0/24;
|
|
|
|
location /static/ {
|
|
alias /var/lib/mailman-web/static/;
|
|
}
|
|
|
|
location /pipermail/ {
|
|
alias /var/lib/mailman2/archives/public/;
|
|
}
|
|
|
|
# disabled mbox.gz thread export abused by scrapers costly to generate
|
|
location ~ ^/archives/list/[^/]+/export/ {
|
|
return 404;
|
|
}
|
|
|
|
# Cache archive list/thread/message pages
|
|
location ~ ^/(archives|hyperkitty)/list/[^/]+/ {
|
|
if ($mailman_blocked_ua) {
|
|
return 444;
|
|
}
|
|
limit_req zone=mailmanlimit burst=5 nodelay;
|
|
limit_conn mailmanconn 20;
|
|
include /etc/nginx/uwsgi_params;
|
|
uwsgi_param HTTPS on;
|
|
uwsgi_pass unix:/run/mailman-web/mailman-web.sock;
|
|
|
|
uwsgi_cache mailmancache;
|
|
uwsgi_cache_key $scheme$host$uri$args;
|
|
uwsgi_cache_valid 200 15m;
|
|
uwsgi_cache_bypass $cookie_sessionid;
|
|
uwsgi_no_cache $cookie_sessionid;
|
|
uwsgi_cache_lock on;
|
|
uwsgi_cache_use_stale error timeout updating http_500 http_503;
|
|
# Django mints a fresh csrftoken cookie on every response, which
|
|
# would otherwise stop this from ever caching.
|
|
uwsgi_ignore_headers Set-Cookie;
|
|
uwsgi_hide_header Set-Cookie;
|
|
add_header X-Cache-Status $upstream_cache_status;
|
|
}
|
|
|
|
# Heavy search endpoint: stricter limit.
|
|
location ~ ^/(archives|hyperkitty)/search {
|
|
if ($mailman_blocked_ua) {
|
|
return 444;
|
|
}
|
|
limit_req zone=mailmansearch burst=5 nodelay;
|
|
limit_conn mailmanconn 20;
|
|
include /etc/nginx/uwsgi_params;
|
|
uwsgi_param HTTPS on;
|
|
uwsgi_pass unix:/run/mailman-web/mailman-web.sock;
|
|
}
|
|
|
|
location / {
|
|
if ($mailman_blocked_ua) {
|
|
return 444;
|
|
}
|
|
limit_req zone=mailmanlimit burst=5 nodelay;
|
|
limit_conn mailmanconn 20;
|
|
include /etc/nginx/uwsgi_params;
|
|
uwsgi_param HTTPS on;
|
|
uwsgi_pass unix:/run/mailman-web/mailman-web.sock;
|
|
}
|
|
}
|