apiVersion: v1 kind: ConfigMap metadata: name: ingress-catchall namespace: ingress-nginx data: nginx.conf: | worker_processes 1; pid /tmp/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; client_body_temp_path /tmp/client_temp; proxy_temp_path /tmp/proxy_temp; fastcgi_temp_path /tmp/fastcgi_temp; uwsgi_temp_path /tmp/uwsgi_temp; scgi_temp_path /tmp/scgi_temp; server { listen 8080; server_name _; root /usr/share/nginx/html; error_page 403 =404 /index.html; # Only GET is intentionally accepted by this catch-all. # The "if" is safe here because it only performs a return. # Serve robots.txt directly with Disallow: / location = /robots.txt { default_type text/plain; return 200 "User-agent: *\nDisallow: /\n"; } # Deliberately trigger an internal 403 so the static error page is # returned with the externally visible status still set to 404. location / { if ($request_method != GET) { add_header Allow GET always; return 405; } deny all; } # Keep the error document internal so /index.html also follows the # catch-all policy instead of becoming a successful public endpoint. location = /index.html { internal; allow all; } } } index.html: | Not found

404

There is nothing here.

The requested resource does not exist on this ingress endpoint.

--- apiVersion: apps/v1 kind: Deployment metadata: name: ingress-catchall namespace: ingress-nginx labels: app.kubernetes.io/name: ingress-catchall app.kubernetes.io/part-of: ingress-nginx spec: replicas: 2 selector: matchLabels: app.kubernetes.io/name: ingress-catchall template: metadata: labels: app.kubernetes.io/name: ingress-catchall app.kubernetes.io/part-of: ingress-nginx spec: automountServiceAccountToken: false securityContext: seccompProfile: type: RuntimeDefault containers: - name: nginx image: nginx:1.27-alpine imagePullPolicy: IfNotPresent ports: - name: http containerPort: 8080 securityContext: allowPrivilegeEscalation: false capabilities: drop: ["ALL"] runAsNonRoot: true runAsUser: 101 volumeMounts: - name: config mountPath: /etc/nginx/nginx.conf subPath: nginx.conf readOnly: true - name: config mountPath: /usr/share/nginx/html/index.html subPath: index.html readOnly: true readinessProbe: tcpSocket: port: http periodSeconds: 5 livenessProbe: tcpSocket: port: http initialDelaySeconds: 5 periodSeconds: 10 volumes: - name: config configMap: name: ingress-catchall --- apiVersion: v1 kind: Service metadata: name: ingress-catchall namespace: ingress-nginx labels: app.kubernetes.io/name: ingress-catchall app.kubernetes.io/part-of: ingress-nginx spec: selector: app.kubernetes.io/name: ingress-catchall ports: - name: http port: 80 targetPort: http