interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / infra / spark / edge-http-nft.awk

21 lines · 1285 bytes Raw Blame History
1# Firewall transform for spark/edge-http-apply.sh (and test/http80-netns.sh): reads the live
2# /etc/atlas/ingress.nft and prints it with exactly two additions, every other line unchanged:
3# 1. after the :443 front-door accept rule, an accept for 4480 that matches only connections the
4# prerouting redirect below rewrote from port 80 (ct original proto-dst 80);
5# 2. before the table's closing brace (the last line), the chain http80_redirect, which rewrites
6# public TCP 80 on enP7s7 to 192.168.1.108:4480 (nginx sites-http-redirect).
7{ lines[NR] = $0 }
8END {
9 r443 = "iifname \"enP7s7\" ip daddr 192.168.1.108 tcp dport 443 accept"
10 for (i = 1; i <= NR; i++) {
11 if (i == NR) {
12 print "\tchain http80_redirect {"
13 print "\t\ttype nat hook prerouting priority dstnat; policy accept;"
14 print "\t\tiifname \"enP7s7\" ip daddr 192.168.1.108 tcp dport 80 redirect to :4480 comment \"Spark front door: public http -> nginx 301 to https (apache2 keeps *:80, unreachable)\""
15 print "\t}"
16 }
17 print lines[i]
18 if (index(lines[i], r443) > 0)
19 print "\t\tiifname \"enP7s7\" ip daddr 192.168.1.108 tcp dport 4480 ct original proto-dst 80 accept comment \"Spark front door: public http, only as redirected from :80 (edge-http-apply.sh)\""
20 }
21}