Add basic rate limiting to reduce contact form spam (1290e900) · Commits · Sturm / Brown Hill Community Hub website · GitLab
Ben Sturmfel
·
2026-06-24
·
via Ben Sturmfels activity
| Original line number |
Diff line number |
Diff line |
|
|
# Directory contact form POST requests must come > 30 sec after form get request.
|
|
|
limit_req_zone $binary_remote_addr zone=contact_form_req:10m rate=2r/m
|
|
|
|
|
|
server {
|
|
|
listen 80;
|
|
|
listen 443 ssl;
|
|
@@ -22,14 +25,17 @@ server { |
|
|
include uwsgi_params;
|
|
|
proxy_set_header X-Forwarded-Protocol $scheme;
|
|
|
uwsgi_pass unix:/tmp/brownhill_django.sock;
|
|
|
}
|
|
|
|
|
|
# Prevent Nginx from hanging up on uWSGI, causing "OSError: write error"
|
|
|
# when a client disconnects before uWSGI has responded. My theory is that by
|
|
|
# setting Nginx timeouts to 16 seconds and uWSGI harakiri to 15 seconds,
|
|
|
# uWSGI should always timeout first.
|
|
|
uwsgi_ignore_client_abort on;
|
|
|
uwsgi_read_timeout 16s;
|
|
|
uwsgi_send_timeout 16s;
|
|
|
location ~ /contact/$ {
|
|
|
include uwsgi_params;
|
|
|
proxy_set_header X-Forwarded-Protocol $scheme;
|
|
|
uwsgi_pass unix:/tmp/brownhill_django.sock;
|
|
|
# Rate limit the directory contact form endpoint to prevent spam. This blocks
|
|
|
# POST requests that occur immediately after a GET request. Simple, but seems to
|
|
|
# be effective so far.
|
|
|
limit_req zone=contact_form_req;
|
|
|
limit_req_status 429;
|
|
|
}
|
|
|
|
|
|
# March 2019: Redirect to new hall site.
|
|
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。