about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPjotr Prins <pjotr.public01@thebird.nl>2026-12-01 10:04:21 +0000
committerPjotr Prins <pjotr.public01@thebird.nl>2026-12-01 10:04:21 +0000
commit2b144b691b79206ef5d4f8a0ae39c5baaddd2ea2 (patch)
tree9bdd88d81e8ad3508a4f62a1378932a10abb79aa
parent18938cec613dac4998f2749499b3ac7259dc8cfc (diff)
downloadgenenetwork4-2b144b691b79206ef5d4f8a0ae39c5baaddd2ea2.tar.gz
nginx: the host root answers nothing, instead of "Hello, world!"
Visiting the hostname redirected to /gn4/ and printed GN4's welcome, which
tells anyone who finds the host that there is an API behind it and invites a
probe. The mount point is /gn4/; the root now holds the request open and
answers with nothing at all -- no page, no redirect, no status line to report.

proxy_pass points at TEST-NET-1 (RFC 5737), which is never routed, so the
connect attempt simply goes nowhere and the visitor's browser gives up first;
the 300s timeouts are the backstop, not the intent. Measured on this host's
nginx 1.26.3 in a scratch instance: /ok answered in 0.5 ms while / hit curl's
5s timeout (exit 28), and `nginx -t' accepted the configuration.

Holding a request costs a socket, so limit_conn caps it at four per address --
a scanner cannot park threads on the root without a lot of addresses. The
comment carries the cheaper alternative (`return 444'), which closes the
connection with no reply and is what to switch to if this ever looks like it
is costing more than it is worth.

/gn4/ is untouched: it is where the API, the skill and every client live.
-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/ {