I would like to share an Ansible-based setup for Ingress hardening and firewall automation in my homelab and kindly ask for constructive feedback from the community.
The main goal was to establish a clearly scoped, reproducible, and tested reference state for a single Internet-facing Ingress host.
Focus areas
Firewall hardening using nftables (default-deny, explicit allow rules)
Reverse proxy (nginx) as the single external entry point
Clear separation between Ingress security and application behavior
Practical testing of allowed and disallowed access
(HTTP/HTTPS, sensitive paths, HTTP methods)
Documentation of decisions and consciously accepted trade-offs
Just stumbled upon this post, I had quick skim through the repo as I don’t have much time. I don’t see any real issues with it from the start, apart from 1 (small) thing, FQCN is not used everywhere. It’s highly suggested to do so, see this page.
In short, use “ansible.builtin.file” instead of just “file”.
Once nginx is the only host nftables accepts from the WAN, the proxy config matters more than extra allow rules.
Terminate TLS only on that ingress box. Application ports should listen on loopback or an internal NIC that the default-deny table never opens to the internet. Give the catch-all server default_server and return 444 for unknown SNI or Host so a scan does not hit a real vhost.
Do not append client-supplied forwarding headers. Set X-Forwarded-For, X-Real-IP, and X-Forwarded-Proto yourself, and set the proto to https only on the TLS server. If you append, anyone who can open a connection can spoof the chain.
Keep port 80 for ACME http-01 and redirect every other request. Enable HSTS only after every name you serve has a valid certificate, and never on the default server.
Do the tests cover applying the role twice and handling a failed configuration reload? For an ingress host, I’d want to know that a second run leaves the rules unchanged and that an invalid new configuration doesn’t remove the working one. What’s the recovery path if a firewall change blocks the management connection? These checks would make the reference state easier to operate, beyond verifying which HTTP requests are allowed or denied.