Ver código fonte

feat(prod): brand the error pages on the old hostname and the catch-all too

The snippet was written to be included per server block, so this is one
line in each of four places: the old name's qdrant block on :6334, its
/rag/ block on :443, its port-80 redirect block, and the default
catch-all that a request to the bare IP or an unknown hostname lands on.
Every nginx-raised error on the box is now branded.

Nothing proxied changed, which is the part worth checking rather than
assuming: qdrant still answers its own JSON on :6334 and the whole /rag/
surface is untouched, because proxy_intercept_errors remains off. The old
hostname fronts a service that is not ours, so that was the risk here.

Still stock, and deliberately left alone: the bare IP's root serves
Debian's "Welcome to nginx!" page. It is a 200 rather than an error, so
error_page does not reach it, and replacing it is a real trade rather
than a tidy-up - branding it would tell a scanner whose box this is,
where the stock page says nothing about us.
fszontagh 1 mês atrás
pai
commit
9ea0a6ef6c

+ 10 - 3
packaging/nginx/README.md

@@ -13,10 +13,17 @@ The host is the source of truth; this is the backup and the review surface.
 | `vectorapi-proxy.conf` | `/etc/nginx/snippets/vectorapi-proxy.conf` |
 | `branded-errors.conf` | `/etc/nginx/snippets/branded-errors.conf` |
 | `errors/_brand/*` | `/var/www/smartbotics-errors/_brand/` |
+| `qdrant-1.shop.static.shopcall.ai.conf` | `/etc/nginx/sites-available/qdrant-1.shop.static.shopcall.ai` |
+| `default.conf` | `/etc/nginx/sites-available/default` |
 
-The older hostname's config (`qdrant-1.shop.static.shopcall.ai`, mount `/rag/`)
-is deliberately NOT copied here: it also fronts another service, so this repo is
-the wrong place for it.
+The last two are copied for recovery and review only. The old hostname also
+fronts **qdrant** on `142.93.100.6:6334`, which has nothing to do with this
+service, so change them on the host with that in mind. `default` is the
+catch-all a request to the bare IP or an unknown hostname lands on.
+
+All four server blocks across those two files include `branded-errors.conf`,
+so every nginx-raised error on this box is branded. Verified afterwards that
+qdrant still answers its own JSON on 6334 and that `/rag/` is untouched.
 
 ## The two things worth reading before editing
 

+ 96 - 0
packaging/nginx/default.conf

@@ -0,0 +1,96 @@
+##
+# You should look at the following URL's in order to grasp a solid understanding
+# of Nginx configuration files in order to fully unleash the power of Nginx.
+# https://www.nginx.com/resources/wiki/start/
+# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
+# https://wiki.debian.org/Nginx/DirectoryStructure
+#
+# In most cases, administrators will remove this file from sites-enabled/ and
+# leave it as reference inside of sites-available where it will continue to be
+# updated by the nginx packaging team.
+#
+# This file will automatically load configuration files provided by other
+# applications, such as Drupal or Wordpress. These applications will be made
+# available underneath a path with that package name, such as /drupal8.
+#
+# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
+##
+
+# Default server configuration
+#
+server {
+	listen 80 default_server;
+	listen [::]:80 default_server;
+
+	# SSL configuration
+	#
+	# listen 443 ssl default_server;
+	# listen [::]:443 ssl default_server;
+	#
+	# Note: You should disable gzip for SSL traffic.
+	# See: https://bugs.debian.org/773332
+	#
+	# Read up on ssl_ciphers to ensure a secure configuration.
+	# See: https://bugs.debian.org/765782
+	#
+	# Self signed certs generated by the ssl-cert package
+	# Don't use them in a production server!
+	#
+	# include snippets/snakeoil.conf;
+
+	root /var/www/html;
+
+	# Add index.php to the list if you are using PHP
+	index index.html index.htm index.nginx-debian.html;
+
+	server_name _;
+
+	# Branded error pages. This is the catch-all: a request to the bare IP
+	# or an unknown hostname lands here, so it is the most likely place a
+	# stranger meets us.
+	include /etc/nginx/snippets/branded-errors.conf;
+
+	location / {
+		# First attempt to serve request as file, then
+		# as directory, then fall back to displaying a 404.
+		try_files $uri $uri/ =404;
+	}
+
+	# pass PHP scripts to FastCGI server
+	#
+	#location ~ \.php$ {
+	#	include snippets/fastcgi-php.conf;
+	#
+	#	# With php-fpm (or other unix sockets):
+	#	fastcgi_pass unix:/run/php/php7.4-fpm.sock;
+	#	# With php-cgi (or other tcp sockets):
+	#	fastcgi_pass 127.0.0.1:9000;
+	#}
+
+	# deny access to .htaccess files, if Apache's document root
+	# concurs with nginx's one
+	#
+	#location ~ /\.ht {
+	#	deny all;
+	#}
+}
+
+
+# Virtual Host configuration for example.com
+#
+# You can move that to a different file under sites-available/ and symlink that
+# to sites-enabled/ to enable it.
+#
+#server {
+#	listen 80;
+#	listen [::]:80;
+#
+#	server_name example.com;
+#
+#	root /var/www/example.com;
+#	index index.html;
+#
+#	location / {
+#		try_files $uri $uri/ =404;
+#	}
+#}

+ 64 - 0
packaging/nginx/qdrant-1.shop.static.shopcall.ai.conf

@@ -0,0 +1,64 @@
+server {
+    server_name qdrant-1.shop.static.shopcall.ai;
+    # Branded error pages for the errors nginx itself raises. Proxied
+    # responses are untouched: proxy_intercept_errors stays off, so both
+    # qdrant and vectorapi keep their own JSON error bodies.
+    include /etc/nginx/snippets/branded-errors.conf;
+        location / {
+        proxy_pass http://127.0.0.1:6333;
+    }
+
+
+    listen 142.93.100.6:6334 ssl; # managed by Certbot
+    ssl_certificate /etc/letsencrypt/live/qdrant-1.shop.static.shopcall.ai/fullchain.pem; # managed by Certbot
+    ssl_certificate_key /etc/letsencrypt/live/qdrant-1.shop.static.shopcall.ai/privkey.pem; # managed by Certbot
+    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
+    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
+
+}
+
+server {
+    server_name qdrant-1.shop.static.shopcall.ai;
+    # Branded error pages for the errors nginx itself raises. Proxied
+    # responses are untouched: proxy_intercept_errors stays off, so both
+    # qdrant and vectorapi keep their own JSON error bodies.
+    include /etc/nginx/snippets/branded-errors.conf;
+    listen 443 ssl;
+    ssl_certificate /etc/letsencrypt/live/qdrant-1.shop.static.shopcall.ai/fullchain.pem; # managed by Certbot
+    ssl_certificate_key /etc/letsencrypt/live/qdrant-1.shop.static.shopcall.ai/privkey.pem; # managed by Certbot
+    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
+    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
+
+    # toloajto RAG (smartbotic-vectorapi). /rag/ -> 127.0.0.1:8080 (trailing slash strips /rag).
+    # CORS + origin-pinning are handled by the vectorapi itself.
+    location /rag/ {
+        proxy_pass http://127.0.0.1:8080/;
+        proxy_set_header Host $host;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_set_header X-Forwarded-Proto $scheme;
+        # A POST /vectors embeds server-side, so the embedding provider's
+        # latency sits inside this request: ~9.7s cold, and occasionally
+        # past the 60s default. Three writes died that way on 2026-09-23,
+        # logged as "upstream timed out while reading response header".
+        proxy_read_timeout 180s;
+        client_max_body_size 10m;
+    }
+}
+
+server {
+    if ($host = qdrant-1.shop.static.shopcall.ai) {
+        return 301 https://$host$request_uri;
+    } # managed by Certbot
+
+
+    server_name qdrant-1.shop.static.shopcall.ai;
+    # Branded error pages for the errors nginx itself raises. Proxied
+    # responses are untouched: proxy_intercept_errors stays off, so both
+    # qdrant and vectorapi keep their own JSON error bodies.
+    include /etc/nginx/snippets/branded-errors.conf;
+    listen 80;
+    return 404; # managed by Certbot
+
+
+}