about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--etc/nginx-vesuvio.pu.ac.ke.conf33
1 files changed, 30 insertions, 3 deletions
diff --git a/etc/nginx-vesuvio.pu.ac.ke.conf b/etc/nginx-vesuvio.pu.ac.ke.conf
index d58b3b4..c8b24ea 100644
--- a/etc/nginx-vesuvio.pu.ac.ke.conf
+++ b/etc/nginx-vesuvio.pu.ac.ke.conf
@@ -9,6 +9,11 @@ log_format gn4 '$remote_addr - $remote_user [$time_local] "$request" '
 # Uncomment with the limit_req line inside the location below.
 # limit_req_zone $binary_remote_addr zone=gn4_per_ip:10m rate=20r/s;
 
+# The root location holds a request open (see `location = /` in the server
+# block), and a held request costs a socket: cap it per address so a scanner
+# cannot park threads on it. 1m of zone is roughly 32k addresses.
+limit_conn_zone $binary_remote_addr zone=gn4_root:1m;
+
 # nginx: https://vesuvio.pu.ac.ke/gn4/ -> genenetwork4 on 127.0.0.1:3000
 #
 # Drop into /etc/nginx/conf.d/ (included from inside nginx's http block) or
@@ -67,9 +72,31 @@ server {
     access_log /var/log/nginx/gn4.access.log gn4;
     error_log  /var/log/nginx/gn4.error.log;
 
-    # Bare host: send people to the mount point rather than the catch-all
-    # 404 below. Drop this if the host root should stay empty.
-    location = /   { return 302 /gn4/; }
+    # The bare host answers nothing at all. /gn4/ is the interface; a visit to
+    # the hostname is not an invitation to look around, and a "Hello, world!"
+    # at the root is an invitation to start probing.
+    #
+    # The request is held open rather than refused: no page, no redirect, no
+    # status line to report. proxy_pass points at TEST-NET-1 (RFC 5737), which
+    # is never routed, so the connection attempt goes nowhere and the visitor's
+    # browser gives up first (the 300s timeouts are the backstop, not the
+    # intent).
+    #
+    # `return 444' is the cheaper, conventional way to say the same thing: it
+    # closes the connection with no reply, which a client reports immediately
+    # as an empty reply instead of waiting. Use it if holding sockets ever
+    # becomes a problem; limit_conn below is what keeps that bounded today.
+    location = / {
+        proxy_pass http://192.0.2.1:9;
+        proxy_connect_timeout 300s;
+        proxy_read_timeout    300s;
+        proxy_send_timeout    300s;
+        proxy_next_upstream   off;
+        limit_conn gn4_root 4;
+        access_log off;
+        error_log /dev/null emerg;
+    }
+
     location = /gn4 { return 301 /gn4/; }
 
     location /gn4/ {