Blog security overview

Hardening self-hosted infrastructure with OPNsense GeoIP bans, Suricata IPS, Tor blocking, NGINX ModSecurity WAF rules, and automated reporting.

Blog security overview

Agenda

  1. GeoIP DenyList (MaxMind, Tor, Individual IP ,etc.)
  • Attack Surface Reduction
  • Resource & Noise Reduction 2. Intrusion Detection (Suricata)

  • Deep Packet Inspection (DPI) & Threat Response

  • Suricata Enabled Rulesets
  • abuse.ch Rulesets (Feodo Tracker, ThreatFox, URLhaus)
  • Emerging Threats (ET) Rulesets 3. OPNsense Firewall

  • Port forwarding strategy 4. NGINX Ingress

  • Bypassing Kubernetes internal NAT for Real IP visibility (hostNetwork: true) 5. NGINX ModSecurity WAF

  • The "Golden" Helm Configuration

  • Locking down ghost admin api to private local and VPN CIDRs
  • Resource Protection & DoS Prevention settings
  • Traffic Integrity & Encryption (ssl-redirect)
  • Timeout Management 6. The "Silent Treatment": Why Your WAF and IPS Should Be Best Friends 7. Resource Protection & DoS Prevention

  • DDoS Mitigation: Beyond the Signature

  • Routing & Request Header Control
  • Network Segmentation (ingress.class)
  • Security Headers & Host Header Injection Prevention 8. Ghost SMTP Signup Security

  • Custom Python Denylist script

  • Blocking disposable email domains 9. SSL Certificates

  • cert-manager & Let's Encrypt integration

  • DNS-01 Challenge & Automated Renewals 10. Analytics

GeoIP DenyList - MaxMind GeoIP, Tor, Individual DenyList

Security is about reducing the attack surface. By using a GeoIP denylist, I'm essentially closing off network paths that I know I don't need. It’s a proactive way to mitigate brute-force attacks and vulnerability probing before they even hit my NGINX Ingress. If you’re trying to access the site from a blocked region and have a legitimate reason to be here, feel free to reach out via my socials.

I created an alias and firewall rule which explicitly bans all Tor exit node traffic from accessing my site in any way. This prevents individuals from attempting to hack my system outside of IP monitoring. OPNsense supports this through aliases and using a tor exit node url which gets updated frequently and automatically. Most of these hacks are pretty pathetic but I don't want this noise in my logs.

When configuring the tor alias make sure you use a URL Table. This enables refresh on any interval you are interested in. You can update this list to every 60 seconds if you want to be extra secure when additional exit nodes are added to the network.

https://check.torproject.org/torbulkexitlist

I also maintain an IP blocklist which I will soon have integrated with OPNsense alias Block_IPs and automated hacker reporting to authorities. So feel free to try and hack me. I do enjoy it. Note you can also use ET open/tor in Suricata to do this blocklist. I chose to ban it entirely.


Key points:

  • Attack Surface Reduction: Making the "target" smaller.
  • Resource Management: Not wasting CPU/RAM on bots.
  • Noise Reduction: Keeping logs clean so you can see actual issues.

Blog security overview: GeoIP DenyList - MaxMind GeoIP, Tor, Individual DenyList

Create a firewall alias and download the geoip data.

MaxMind GeoIP’s Setup - OPNsense documentation

Blog security overview: GeoIP DenyList - MaxMind GeoIP, Tor, Individual DenyList

Select the countries you want to block

Blog security overview: GeoIP DenyList - MaxMind GeoIP, Tor, Individual DenyList

Block unwanted traffic like tor, blocked countries, specific IPs at the front door

Trust but verify. Just kidding. Never trust anything always verify. I used this site to confirm implementation success.

To be perfectly honest here MaxMind has some major missing CIDR ranges for traffic coming from countries I have banned. I might create my own list or look for better "free" alternatives. MaxMind and others have paid lists I might look at when at scale. I think every hacker that tries to run some hacking software against my systems an immediate ban and automatically adding to an alias IP banlist should work out fine I think. As long as the list doesn't get too long.

Ping server, ping website : Check host - online website monitoring Ping server and website online: website monitoring with useful tools, Check IP, Check website I used this site to confirm denial across many of the countries I currently block

Intrusion Detection - Suricata

Implementing Suricata as part of my stack is about moving from passive logging to active network defense. While standard firewalls handle basic access control, Suricata provides Deep Packet Inspection (DPI), allowing me to see exactly what is happening inside the traffic.

I use it for a few specific reasons:

  • Intrusion Detection & Prevention: It analyzes every packet against a massive library of known signatures (like the Emerging Threats and abuse.ch rulesets). If a request matches a pattern for a known exploit or a malware "phone home" signal, Suricata identifies it in real-time.
  • Protocol Analysis: Beyond just looking at ports, it understands protocols. It can see if an attacker is trying to hide malicious commands inside legitimate-looking HTTP or TLS traffic.
  • Visibility into Lateral Movement: It’s not just about the front door. Suricata helps monitor internal traffic, which is crucial for identifying if a single compromised service is attempting to scan or infect other parts of my network.
  • Automatic Threat Response: By integrating it with my firewall, I can move from just "detecting" to "blocking" - automatically dropping traffic from IPs that exhibit confirmed malicious behavior.

Ultimately, it gives me a "security camera" for my network traffic, providing the forensic data I need to understand how an attack was attempted and the automated tools to stop it before it reaches my data.

Suricata Enabled Rulesets

Blog security overview: Suricata Enabled Rulesets

The following is just an example of the rules you would at least want to use when hosting a web server. I have many more rules enabled and set to enforce which I am not showing here. The post would become too long to list them all.

abuse.ch Rulesets

These are highly specific feeds from a trusted Swiss security project.

  • Feodo Tracker: Targets botnet infrastructure associated with the Feodo (Dridex/Emotet) family.
  • SSL Fingerprint Blacklist: Blocks malicious SSL/TLS handshakes based on specific "JA3" fingerprints used by malware.
  • SSL IP Blacklist: Blocks IP addresses associated with malicious SSL certificates.
  • ThreatFox: A multi-layered feed of "Indicators of Compromise" (IOCs) including malware C2s and payloads.
  • URLhaus: Targets URLs used for malware distribution and payload hosting.

Emerging Threats (ET) Rulesets

These are broader categories from Proofpoint’s Emerging Threats community feed.

  • open/compromised: A list of known compromised hosts and "bad" IP reputations.
  • emerging-exploit: Detects active attempts to exploit known software vulnerabilities (CVEs).
  • emerging-exploit_kit: Specifically targets traffic patterns of "Exploit Kits" (automated toolkits used to infect users via browsers).
  • emerging-ja3: Identifies malicious software by its unique SSL/TLS "fingerprint" (the specific combination of cryptographic settings used in the handshake), allowing the IPS to detect and block tools like malware or botnets even inside encrypted traffic without needing decryption.
  • emerging-malware: Detects the "phone home" or C2 traffic of active malware infections.
  • emerging-mobile_malware: Focuses on threats targeting Android and iOS devices.
  • emerging-scan: Identifies reconnaissance activity, such as port scanners and vulnerability mappers.
  • emerging-user_agents: Flags suspicious or malicious "User-Agent" strings (e.g., a browser identifying itself as a known hacking tool).
  • emerging-web_server: Protects web servers from inbound attacks like SQL injection or path traversal.
  • emerging-web_specific_apps: Targeted rules for vulnerabilities in specific CMS/apps like WordPress, Joomla, or Drupal.
  • emerging-worm: Detects self-propagating malware that attempts to spread across a network.

Blog security overview: Emerging Threats (ET) Rulesets

You can enable whatever you want if you have the router capable of handling it

Blog security overview: Emerging Threats (ET) Rulesets

Example of Alerts showing in OPNsense router web ui

OPNsense Firewall

  • 80/443 port forwarded to "external" ingress-nginx

Blog security overview: OPNsense Firewall

Create a rule for both http and https and route to your endpoint lb

NGINX Ingress

I patched my Ingress to bypass Kubernetes' internal NAT.

By default, the container overlay network rewrites packet headers (Source NAT) to route traffic, which unfortunately scrubs the attacker's true IP address and replaces it with the internal gateway IP in my logs.

By setting hostNetwork: true, I am forcing the Ingress controller to bind directly to the bare-metal network interface. This lets it see the raw, unadulterated traffic - real Source IPs included - before the overlay network can mask them. The dnsPolicyline is just the necessary glue; it forces the pod to keep using internal Cluster DNS for service discovery (like finding my Ghost blog) even though it's effectively living 'outside' on the host network.

This stops scanning or hacks which attempt to hide their real ip:

curl -H "X-Forwarded-For: 127.0.0.1" https://www.fracturedarchitecture.com/.env

  • X-Forwarded-For: "$remote_addr"
  • X-Real-IP: "$remote_addr"
  • X-Forwarded-Host:"www.fracturedarchitecture.com"
  • X-Forwarded-Proto: "https"

Note: Setting hostNetwork: true gives the Ingress pod access to the node's loopback device and network interfaces. In a multi-tenant cluster, this is a security risk. Since this is a single-tenant private cluster, the visibility into Real Client IPs outweighs the isolation risk.

NGINX ModSecurity WAF

Securing Kubernetes with NGINX & ModSecurity (The Right Way)

I recently hardened my Kubernetes cluster by deploying the NGINX Ingress Controller with the ModSecurity WAF enabled. My goal was simple: get the full protection of the OWASP Core Rule Set (CRS) to block SQL injection and XSS attacks, while keeping the flexibility to whitelist my specific apps like Ghost. This is basically another layer of highly specialized Intrusion Prevention System (IPS) for Layer 7 (HTTP/HTTPS). OPNsense handles Deep Packet Inspection and ModSecurity handles Deep Request Inspection since ingress-nginx is the first layer that sees the real decrypted traffic. nginx is the TLS termination point in the cluster.

Getting it to work wasn't just a toggle switch. I had to solve for Real IP visibility (using hostNetwork: true)

Here is the "Golden Configuration" that finally got everything working - stable, secure, and logging attacks in clean JSON format.

The Winning Helm Configuration

controller:
  # 1. Network Performance & Real IPs
  hostNetwork: true
  dnsPolicy: ClusterFirstWithHostNet

  # 2. WAF Configuration
  config:
    enable-modsecurity: "true"
    enable-owasp-core-rules: "true" 
    allow-snippet-annotations: "true"

    modsecurity-snippet: |
      # Phase logic exception
      Include /etc/nginx/owasp-modsecurity-crs/plugins/ghost-rules.conf

      # Enable Active Blocking (Not just detection)
      SecRuleEngine On
      SecRequestBodyAccess On
      SecRequestBodyLimitAction Reject

      # JSON Logging to Stdout (for easy parsing)
      SecAuditLog /dev/stdout
      SecAuditLogFormat JSON
      SecAuditEngine RelevantOnly

  # 3. Mount the Custom Rules
  extraVolumes:
    - name: custom-rules
      configMap:
        name: customizations
  extraVolumeMounts:
    - name: custom-rules
      mountPath: /etc/nginx/owasp-modsecurity-crs/plugins

Example helm chart values.yaml for a secure deployment of ingress-nginx

Ghost Specific WAF Rules

I locked down the ghost admin endpoints to my specific internal CIDRs and VPN CIDRs. This further enhances security preventing even the attempt at hacking my blog from outside of a network I control. Essentially the only accessible resources will be the ones that need to be publicly available. So if the ghost admin api contains a critical bug at any point the only one who can exploit it is users on my network. This could also be done with ingress routes but I decided to use the WAF instead.

apiVersion: v1
kind: ConfigMap
metadata:
  name: customizations
  namespace: ingress-nginx-external
data:
  empty-after.conf: ""
  empty-before.conf: ""
  empty-config.conf: ""

  ghost-rules.conf: |
    # ==========================================================
    # GHOST WAF MASTER CONFIGURATION
    # ==========================================================

    # --- PHASE 1: GLOBAL BLOCKLIST (Bad Traffic) ---

    # 1. Block WordPress Scanners (Noise reduction)
    SecRule REQUEST_URI "@beginsWith /wp-" \
      "id:10001,phase:1,deny,status:444,msg:'Blocked WordPress Scanner',logdata:'%{MATCHED_VAR}'"

    # 2. Block Sensitive System Files
    SecRule REQUEST_URI "@rx \.(?:env|git|svn|htaccess|docker|yml|yaml)$" \
      "id:10002,phase:1,deny,status:403,msg:'Attempted Access to Sensitive File'"

    # --- PHASE 2: PUBLIC ALLOWLIST (The "Safe Zones") ---
    # These rules allow traffic to bypass the custom Admin Block (Rule 10004).
    # We keep 'ctl:ruleEngine=On' so OWASP Core Rules still scan for attacks (XSS/SQLi).

    # 3. Allow Public Content API (Theme Data)
    SecRule REQUEST_URI "@beginsWith /ghost/api/content/" \
      "id:10003,phase:1,allow,nolog,ctl:ruleEngine=On"

    # 4. Allow Ghost Assets (Fonts/Scripts)
    SecRule REQUEST_URI "@beginsWith /ghost/assets/" \
      "id:10006,phase:1,allow,nolog,ctl:ruleEngine=On"

    # 5. Allow Member Interaction (Login, Logout, Comments, Webhooks)
    # This covers:
    #   - /members/api/session/ (Login/Logout)
    #   - /members/api/send-magic-link/ (Signup)
    #   - /members/api/comments/ (Posting Comments)
    #   - /members/webhooks/ (Stripe/Mailgun)
    SecRule REQUEST_URI "@beginsWith /members/" \
      "id:10007,phase:1,allow,nolog,ctl:ruleEngine=On"

    # --- PHASE 3: ADMIN LOCKDOWN (The "Vault") ---

    # 6. Bypass WAF for Authorized Admin (YOU)
    # If it is the Admin URL AND your IP -> Allow & Disable Engine (No false positives).
    SecRule REQUEST_URI "@beginsWith /ghost/" \
      "id:10005,phase:1,allow,nolog,ctl:ruleEngine=Off,chain"
      SecRule REMOTE_ADDR "@ipMatch 10.0.0.0/8,192.168.0.0/16"

    # 7. Block Everyone Else from Admin
    # If we reached this point, it is a /ghost/ request from a Stranger.
    SecRule REQUEST_URI "@beginsWith /ghost/" \
      "id:10004,phase:1,deny,status:403,msg:'Blocked External Admin Access'"

Lock down ghost admin endpoint to only internal and vpn CIDRs

Handling False Positives (The Ghost Admin Fix)

Ghost's admin API sends complex JSON payloads containing HTML and code snippets. This triggers multiple WAF rules and skyrockets the Anomaly Score, causing a block even if you whitelist individual rules.

One alternative way to fix this is to completely disable the WAF engine for the Admin API path (/ghost/api/), relying on Ghost's built-in authentication instead. I chose to secure the admin endpoint to my internal network CIDRs. This approach is better but only if you can guarantee source IP address.

apiVersion: v1
kind: ConfigMap
metadata:
  name: customizations
  namespace: ingress-nginx-external
data:
  ghost-rules.conf: |
    # 1. BLOCK NOISE (WordPress Bots)
    SecRule REQUEST_URI "@beginsWith /wp-" \
      "id:10001,phase:1,deny,status:444,msg:'Blocked WordPress Scanner'"

    # 2. ALLOW GHOST ADMIN (The Critical Fix)
    # The Admin API (/ghost/api/) sends content that looks like attacks.
    # We must disable the engine for this path to prevent the Anomaly Score from blocking valid saves.
    SecRule REQUEST_URI "@beginsWith /ghost/api/" \
      "id:10005,\
      phase:1,\
      pass,\
      nolog,\
      ctl:ruleEngine=Off"

customize the ingress-nginx for your waf requirements

If you're curious to learn more about how to configure this visit the link below.

ModSecurity Web Application Firewall - Ingress-Nginx Controller

Here is an example of what I log in case you are curious.

Click here to view the full WAF Log (JSON)
    2026/02/08 17:26:52 [error] 2237#2237: *74615 [client [CLIENT_IP]] ModSecurity: Access denied with code 403 (phase 2). Matched "Operator `Ge' with parameter `5' against variable `TX:BLOCKING_INBOUND_ANOMALY_SCORE' (Value: `5' ) [file "/etc/nginx/owasp-modsecurity-crs/rules/REQUEST-949-BLOCKING-EVALUATION.conf"] [line "222"] [id "949110"] [rev ""] [msg "Inbound Anomaly Score Exceeded (Total Score: 5)"] [data ""] [severity "0"] [ver "OWASP_CRS/4.22.0"] [maturity "0"] [accuracy "0"] [tag "anomaly-evaluation"] [tag "OWASP_CRS"] [hostname "www.fracturedarchitecture.com"] [uri "/"] [unique_id "177057161231.410939"] [ref ""], client: [CLIENT_IP], server: www.fracturedarchitecture.com, request: "HEAD /?id=1%20OR%201=1 HTTP/2.0", host: "www.fracturedarchitecture.com"

[CLIENT_IP] - - [08/Feb/2026:17:26:52 +0000] "HEAD /?id=1%20OR%201=1 HTTP/2.0" 403 0 "-" "curl/8.17.0" 52 0.000 [ghost-ghost-service-80] [] - - - - a1b6c18e889ab20873ba9e00b3db1a39

{
  "transaction": {
    "client_ip": "[CLIENT_IP]",
    "time_stamp": "Sun Feb  8 17:26:52 2026",
    "server_id": "362463011dcabb932b94eadad106437b4d90e1c3",
    "client_port": 60712,
    "host_ip": "[NODE_IP]",
    "host_port": 443,
    "unique_id": "177057161231.410939",
    "request": {
      "method": "HEAD",
      "http_version": 2.0,
      "uri": "/?id=1%20OR%201=1",
      "body": "",
      "headers": {
        "host": "www.fracturedarchitecture.com",
        "user-agent": "curl/8.17.0",
        "accept": "*/*"
      }
    },
    "response": {
      "http_code": 403,
      "headers": {
        "Server": "",
        "Date": "Sun, 08 Feb 2026 17:26:52 GMT",
        "Content-Length": "146",
        "Content-Type": "text/html",
        "Connection": "close",
        "Strict-Transport-Security": "max-age=31536000; includeSubDomains"
      }
    },
    "producer": {
      "modsecurity": "ModSecurity v3.0.14 (Linux)",
      "connector": "ModSecurity-nginx v1.0.4",
      "secrules_engine": "Enabled",
      "components": [
        "OWASP_CRS/4.22.0\""
      ]
    },
    "messages": [
      {
        "message": "SQL Injection Attack Detected via libinjection",
        "details": {
          "match": "detected SQLi using libinjection.",
          "reference": "v10,8",
          "ruleId": "942100",
          "file": "/etc/nginx/owasp-modsecurity-crs/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf",
          "lineNumber": "46",
          "data": "Matched Data: 1&1 found within ARGS:id: 1 OR 1=1",
          "severity": "2",
          "ver": "OWASP_CRS/4.22.0",
          "rev": "",
          "tags": [
            "application-multi",
            "language-multi",
            "platform-multi",
            "attack-sqli",
            "paranoia-level/1",
            "OWASP_CRS",
            "OWASP_CRS/ATTACK-SQLI",
            "capec/1000/152/248/66"
          ],
          "maturity": "0",
          "accuracy": "0"
        }
      },
      {
        "message": "Inbound Anomaly Score Exceeded (Total Score: 5)",
        "details": {
          "match": "Matched \"Operator `Ge' with parameter `5' against variable `TX:BLOCKING_INBOUND_ANOMALY_SCORE' (Value: `5' )",
          "reference": "",
          "ruleId": "949110",
          "file": "/etc/nginx/owasp-modsecurity-crs/rules/REQUEST-949-BLOCKING-EVALUATION.conf",
          "lineNumber": "222",
          "data": "",
          "severity": "0",
          "ver": "OWASP_CRS/4.22.0",
          "rev": "",
          "tags": [
            "anomaly-evaluation",
            "OWASP_CRS"
          ],
          "maturity": "0",
          "accuracy": "0"
        }
      }
    ]
  }
}


The "Silent Treatment": Why Your WAF and IPS Should Be Best Friends

When an automated scanner or a curious hacker tries to probe my environment, they usually run into my Nginx ingress first. This is a critical design choice: it is where TLS terminates in my cluster, ensuring that my security inspection has full access to the raw, decrypted requests. If a probe triggers a security rule or requests a protected resource, I do not want to be polite.

In a standard setup, a Web Application Firewall (WAF) returns a 403 Forbidden response. That 403 error is a piece of information. It tells the attacker, "Hey, I'm here, and I'm blocking you." Even that tiny bit of feedback confirms the server is alive, identifies the software (often as Nginx), and validates that the attacker has hit a "real" target.

By layering Suricata IPS on top of my Nginx WAF, I have moved to a "Silent Treatment" model where both layers actively drop traffic without sending a response. Here is how it works:

Suricata (The Gatekeeper): Suricata sits in-line on the OPNsense firewall, acting as the first layer of defense. Even though the traffic is encrypted, Suricata can still detect and drop protocol-level attacks. It specifically targets malicious SSL signatures (JA3 fingerprints) and hackers attempting to probe via unencrypted HTTP or known bad user-agents. When these rules trigger, Suricata drops the packet at the wire level. The connection is killed before it ever reaches my internal network or my Nginx ingress.

Nginx (The Executor): For threats hidden inside the valid encrypted traffic, my Nginx Ingress takes over. Since it terminates the TLS connection, it has full visibility into the decrypted payload. When ModSecurity detects an exploit like SQL Injection or a scanner, I use a custom configuration (deny,status:444) to immediately close the connection.

The Result: Whether the attack is caught by Suricata at the handshake level or by Nginx at the application level, the result is the same. The attacker’s terminal just hangs or crashes with a "Connection Reset" or "Protocol Error." They get zero bytes of data. They do not know if they were blocked by a firewall, if the server crashed, or if the IP address is even valid. I still log and audit the hack attempt but the hacker receives no information in their attempt.

Defense in Depth: This combo gives me the best of both worlds: the Layer 3/4 network muscle of Suricata to kill protocol hacks and noise at the perimeter, and the Layer 7 application awareness of Nginx to decrypt and silently drop sophisticated web exploits.

Blog security overview: The "Silent Treatment": Why Your WAF and IPS Should Be Best Friends

Example of a real hacker receiving not a 403 but a dropped packet.

[user@server home]$ curl -vvv -I https://www.fracturedarchitecture.com/wp-admin
* Host www.fracturedarchitecture.com:443 was resolved.
* IPv6: [IPv6_ADDRESS]
* IPv4: [SERVER_IP]
* Trying [IPv6_ADDRESS]:443...
* Immediate connect fail for [IPv6_ADDRESS]: Network is unreachable
* Trying [SERVER_IP]:443...
* Connected to www.fracturedarchitecture.com ([SERVER_IP]) port 443
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / X25519MLKEM768 / RSASSA-PSS
* ALPN: server accepted h2
* Server certificate:
* subject: CN=fracturedarchitecture.com
* start date: Feb 10 07:23:50 2026 GMT
* expire date: May 11 07:23:49 2026 GMT
* issuer: C=US; O=Let's Encrypt; CN=R13
* SSL certificate verified via OpenSSL.
* using HTTP/2
* [HTTP/2] [1] OPENED stream for https://www.fracturedarchitecture.com/wp-admin
* [HTTP/2] [1] [:method: HEAD]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: www.fracturedarchitecture.com]
* [HTTP/2] [1] [:path: /wp-admin]
* [HTTP/2] [1] [user-agent: curl/8.17.0]
* [HTTP/2] [1] [accept: */*]
> HEAD /wp-admin HTTP/2
> Host: www.fracturedarchitecture.com
> User-Agent: curl/8.17.0
> Accept: */*
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* [HTTP/2] [1] <- FRAME[RST_STREAM, len=4, flags=0, error=1]
* [HTTP/2] [1] RESET: PROTOCOL_ERROR (err 1)
* [HTTP/2] [1] returning CLOSE
* HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
* Connection #0 to host www.fracturedarchitecture.com left intact
curl: (92) HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)

Resource Protection & DoS Prevention


DDoS Mitigation: Beyond the Signature

While much of my security stack focuses on blocking specific exploits, Distributed Denial of Service (DDoS) attacks require a different approach. You can't just block a specific payload because, in a flood, the payload is often legitimate traffic. There is just too much of it.

Suricata serves as my primary defense against these volumetric and protocol based attacks by shifting from Deep Packet Inspection to Behavioral Analysis.

  • Protocol Specific Defense (TCP SYN Floods): Suricata monitors the state of every connection. It can identify "half-open" connections where an attacker sends thousands of SYN packets but never completes the handshake. By detecting this pattern early, it can drop the malicious noise before it exhausts the connection table of my Nginx Ingress.
  • Thresholding & Rate Limiting: Using specific threshold and detection filter keywords, I have configured Suricata to monitor packet frequency. If a single IP address or a cluster of IPs exceeds a predefined threshold, such as 100 requests per second, Suricata doesn't just alert. It triggers a drop action at the kernel level.
  • Application Layer (HTTP) Flooding: Even if an attack is encrypted (HTTPS), Suricata’s protocol parsers can identify anomalies in the handshake frequency or the unencrypted SNI (Server Name Indication) headers. This allows it to spot automated "burst" behavior that deviates from typical human browsing patterns.
  • The "Silent Drop" for Floods: Just like with the "Silent Treatment" I use for 403 errors, when Suricata identifies a DDoS flood, it simply stops acknowledging the packets. This forces the attacking botnet to waste resources waiting for a response that will never come, while my Compute resources stay dedicated to real users.

By filtering these protocol level floods at the WAN interface, I ensure that my internal Kubernetes network and Nginx Ingress never even see the garbage traffic, preserving the 20 RPS (Requests Per Second) limit I have set in my Helm configuration for legitimate traffic.

nginx.ingress.kubernetes.io/proxy-body-size: "10m"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
kubernetes.io/ingress.class: "external-nginx"
nginx.ingress.kubernetes.io/proxy-set-headers: "ghost/ghost-custom-headers"
nginx.ingress.kubernetes.io/proxy-host: "www.fracturedarchitecture.com"
nginx.ingress.kubernetes.io/limit-rps: "20"
nginx.ingress.kubernetes.io/limit-burst-multiplier: "5"
nginx.ingress.kubernetes.io/limit-connections: "20"
nginx.ingress.kubernetes.io/proxy-read-timeout: "10"
nginx.ingress.kubernetes.io/proxy-send-timeout: "10"

customize your nginx ingress configuration for rate limiting etc.

These settings prevent attackers from exhausting your server's memory, CPU, or connection slots.

  • proxy-body-size: "10m": Limits the maximum allowed size of the client request body.

  • Security Reason: Prevents Denial of Service (DoS) attacks where an attacker sends massive files to fill up disk space or exhaust memory buffers.

  • limit-rps: "20": Restricts the number of requests per second from a single IP.

  • Security Reason: Mitigates brute-force attacks and application-layer DoS. It ensures one malicious actor cannot monopolize the ingress controller.

  • limit-burst-multiplier: "5": Allows a temporary "burst" of traffic above the RPS limit (in this case, up to 100 requests).

  • Security Reason: Smoothes out legitimate traffic spikes while still providing a hard ceiling to prevent sustained flooding.

  • limit-connections: "20": Limits the number of concurrent connections from a single IP address.

  • Security Reason: Protects against Slowloris style attacks, where an attacker opens many connections and keeps them open as long as possible to exhaust the server's connection pool.

Traffic Integrity & Encryption

  • ssl-redirect: "true": Automatically redirects HTTP traffic to HTTPS (Port 80 to 443).

  • Security Reason: Ensures encryption in transit. It prevents "Man-in-the-Middle" (MitM) attacks where sensitive data (like login cookies) could be intercepted over unencrypted connections.

Timeout Management

  • proxy-read-timeout: "10" & proxy-send-timeout: "10": Sets the maximum time (in seconds) for NGINX to wait for a response from the backend or send a request to it.

  • Security Reason: Aggressive timeouts prevent Resource Exhaustion. Without these, "hanging" backend connections can stay open indefinitely, eventually causing the Ingress controller to run out of worker processes and stop accepting new traffic.

Routing & Request Header Control

  • ingress.class: "external-nginx": Specifies which Ingress controller should handle this configuration.

  • Security Reason:Network Segmentation. This ensures that internal/sensitive services aren't accidentally exposed on an internet-facing Ingress controller.

  • proxy-set-headers: "ghost/ghost-custom-headers": References a ConfigMap containing specific headers to pass to the backend.

  • Security Reason: Often used to inject security headers (like X-Frame-Options or Content-Security-Policy) or to strip dangerous headers sent by the client before they reach your application. I use custom headers to ensure ghost also has the real ip of the client without using a snippet.

  • proxy-host: "www.fracturedarchitecture.com": Explicitly sets the Host header sent to the backend.

  • Security Reason: Prevents Host Header Injection attacks. By hardcoding the expected host, you ensure the backend isn't tricked into processing requests for domains it shouldn't be serving.

Ghost SMTP Signup Security

To prevent spammers from signing up to my site I have configured a denylist which ghost understands how to use. I wrote a custom python script which utilizes disposable-email-domains to generate the necessary ghost configuration file for blocking signups. No email in these domains will be allowed to signup. There are over 4K domains which are banned from signing up to my site. This reduces the likelihood of spammers signing up and that all users are real. It also limits my SMTP exposure and improves site reputation.

Blog security overview: Ghost SMTP Signup Security

Stop spammers at the front door

My ghost-config is in a configmap so this may not work for you but it will give you an idea of how to do it. You essentially want a script that can easily add new domains to this ghost config section.

"spam": { "blocked_email_domains": [ ] }
example spam python script
#!/usr/bin/python3
import yaml
import json
import requests
import os

# Configuration
YAML_FILE_PATH = 'config.production.yaml'
REPO_URL = 'https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/master/disposable_email_blocklist.conf'

# --- CUSTOM YAML FORMATTER ---
def str_presenter(dumper, data):
    """Forces PyYAML to use literal block style '|' for multiline strings"""
    if '\n' in data:
        return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
    return dumper.represent_scalar('tag:yaml.org,2002:str', data)

yaml.add_representer(str, str_presenter)
# -----------------------------

def update_nested_ghost_config():
    # 1. Fetch latest domains
    print("Fetching domains from GitHub...")
    try:
        response = requests.get(REPO_URL)
        response.raise_for_status()
        new_domains = [line.strip() for line in response.text.splitlines()
                       if line.strip() and not line.startswith('#')]
    except Exception as e:
        print(f"Error fetching domains: {e}")
        return

    # 2. Load YAML
    if not os.path.exists(YAML_FILE_PATH):
        print(f"Error: {YAML_FILE_PATH} not found.")
        return

    with open(YAML_FILE_PATH, 'r') as f:
        yaml_data = yaml.safe_load(f)

    # 3. Access the JSON string
    # Assuming standard K8s-style structure: data -> config.production.json
    try:
        json_string = yaml_data['data']['config.production.json']
        config = json.loads(json_string)
    except (KeyError, json.JSONDecodeError) as e:
        print(f"Error accessing internal JSON: {e}")
        return

    # 4. Inject Domains
    if 'spam' not in config:
        config['spam'] = {}

    existing_blocked = set(config['spam'].get('blocked_email_domains', []))
    all_domains = list(existing_blocked.union(set(new_domains)))
    config['spam']['blocked_email_domains'] = sorted(all_domains)

    # 5. Serialize JSON back to string
    # Using indent=4 here makes the internal JSON look clean inside the YAML
    yaml_data['data']['config.production.json'] = json.dumps(config, indent=4)

    # 6. Save YAML
    with open(YAML_FILE_PATH, 'w') as f:
        yaml.dump(yaml_data, f, default_flow_style=False, sort_keys=False, width=1000)

    print(f"Success! Final YAML is now human-readable.")

if __name__ == "__main__":
    update_nested_ghost_config()

GitHub - disposable-email-domains/disposable-email-domains: a list of disposable email domains a list of disposable email domains. Contribute to disposable-email-domains/disposable-email-domains development by creating an account on GitHub.

SSL Certificates

I use cert-manager paired with a** ClusterIssuer** to enforce a standardized encryption policy across my entire infrastructure. This setup moves TLS from a manual, error-prone task to a declarative security standard. By centralizing the issuance logic in a ClusterIssuer, I ensure that every service, regardless of its location in the cluster, follows the same rigorous validation protocols and security standards.

Implementing cert-manager specifically with Let's Encrypt allows me to move away from long-lived, static certificates toward a more secure, short-lived model. By using a trusted, automated Certificate Authority (CA), I can enforce modern encryption standards without the overhead of manual procurement.

Blog security overview: SSL Certificates

Key security advantages include:

  • Elimination of Certificate Expiration: The system automatically handles renewals well before the 90-day mark, removing the 'expired cert' vulnerability that often leads to service downtime or bypassed security checks.
  • Infrastructure-as-Code (IaC) Security: Security is defined at the resource level. By adding a simple annotation to an Ingress, the system automatically provisions a trusted certificate, ensuring that no service is ever accidentally deployed over unencrypted HTTP.
  • DNS-01 Challenge Validation: I leverage the DNS-01 challenge provider to prove domain ownership via API. This is significantly more secure than HTTP-01 as it doesn't require opening firewall holes or exposing temporary web paths for validation.
  • Centralized Governance: Using a ClusterIssuer allows me to manage my Let’s Encrypt or private CA credentials in one secure location, reducing the risk of secret leakage across the cluster.

Google Analytics

Any legitimate user that does get past my inspection I track all user activity using Google Analytics. I know every page you have visited, ever click you have made, how much time you have spent on the page, what you did, how long you read a specific section and even who you are. Don't let that scare you. I'm trustworthy. lol

Blog security overview: Google Analytics

With my setup I should be able to safely handle at least 1M concurrent connections and prevent most DDoS attacks. Should be sufficient for a blog that will get maybe 10 views lol.

That's all for now! Hope you got something out of this. Always open for feedback and improving security posture.

Pseudonymous Peer Review

Field Log Discussion

Public @handle only · Private email hidden · Fenced code blocks supported

0 notes

Join the architecture review under a self-chosen @handle. Your email address is never displayed publicly.

Loading discussion notes...

Open Full ↗
Expanded view
Pseudonymous Identity
Reader Console