max / makenotwork
| 1 | #!/bin/bash |
| 2 | # Firewall setup for Makenotwork production server (ufw). |
| 3 | # |
| 4 | # Rules: |
| 5 | # - Allow all traffic on Tailscale interface (tailscale0) |
| 6 | # - Allow SSH (port 22) from anywhere (needed for git SSH access) |
| 7 | # - Allow HTTP/HTTPS (80/443) from anywhere (custom domains need direct access) |
| 8 | # - Drop everything else |
| 9 | # |
| 10 | # HTTP/HTTPS is open to all because custom domains connect directly (on-demand |
| 11 | # Let's Encrypt TLS, not behind Cloudflare) and arrive from arbitrary client IPs, |
| 12 | # so 443 cannot be CIDR-locked to Cloudflare without breaking that paid feature. |
| 13 | # The IP-spoofing risk this would otherwise create is closed in Caddy instead: |
| 14 | # - makenot.work subdomains: Caddy mTLS (Authenticated Origin Pulls) rejects any |
| 15 | # request without a valid Cloudflare client cert before it reaches the app. |
| 16 | # - custom domains (:443 block): Caddy overwrites CF-Connecting-IP with the real |
| 17 | # TCP peer and strips X-Forwarded-For, so a client cannot forge the source IP |
| 18 | # the app uses for rate-limiting, lockouts, and audit logs. |
| 19 | |
| 20 | |
| 21 | |
| 22 | if [; then |
| 23 | |
| 24 | |
| 25 | fi |
| 26 | |
| 27 | # Reset to defaults |
| 28 | |
| 29 | |
| 30 | # Default policies |
| 31 | |
| 32 | |
| 33 | |
| 34 | # Tailscale — unrestricted |
| 35 | |
| 36 | |
| 37 | # SSH — open from anywhere (git clone over SSH) |
| 38 | |
| 39 | |
| 40 | # HTTP/HTTPS — open to all (custom domains need direct access) |
| 41 | # makenot.work is still protected by Caddy mTLS (Authenticated Origin Pulls) |
| 42 | |
| 43 | |
| 44 | |
| 45 | # Enable |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 |