He leído el hilo y he probado algo yo mismo. Docker trae sus propias reglas de iptables y las aplica después de la instalación o cuando el servicio de docker se reinicia/carga:
service docker restart
Sin estos conjuntos de reglas, la instalación de Discourse no funcionará. Significa que al instalar, reconstruir o reiniciar el contenedor, estas reglas deben estar presentes. De lo contrario, aparecerá el mensaje de error:
Error response from daemon: driver failed programming external connectivity on endpoint app (e4d4d3cc812a11862ee6aaa6ab453e61b95da1e6d90f9a76a71959148d228476): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 443 -j DNAT --to-destination 172.17.0.2:443 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1))
Sin embargo, una vez que la instalación de Discourse está completa o el contenedor se reinicia después de una actualización, las reglas de Docker aparentemente ya no son necesarias. Entonces, se pueden cargar las siguientes reglas de nftables:
#!/usr/sbin/nft -f
####################
# Purge/Flush #
####################
flush ruleset
####################
# Incoming Traffic #
####################
table inet filter {
chain input {
type filter hook input priority 0; policy drop;
# Allow loopback interface
iifname lo accept
# Rate limit ICMPv4|ICMPv6 traffic
ip protocol icmp icmp type { echo-request, echo-reply, destination-unreachable, time-exceeded, parameter-problem, router-solicitation, router-advertisement } limit rate over 5/second drop
ip6 nexthdr icmpv6 icmpv6 type { destination-unreachable, packet-too-big, time-exceeded, echo-request, parameter-problem, echo-reply, nd-router-solicit, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert, ind-neighbor-solicit, ind-neighbor-advert } limit rate over 5/second drop
# Allow packets to established/related connections
ct state established,related accept
# Drop invalid connections
ct state invalid drop
# Allow ICMPv4: Ping requests | Error messages | Router selection messages
ip protocol icmp icmp type { echo-request, echo-reply, destination-unreachable, time-exceeded, parameter-problem, router-solicitation, router-advertisement } accept
# Allow ICMPv6 traffic (https://tools.ietf.org/html/rfc4890#page-18)
ip6 nexthdr icmpv6 icmpv6 type { destination-unreachable, packet-too-big, time-exceeded, echo-request, parameter-problem, echo-reply, nd-router-solicit, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert, ind-neighbor-solicit, ind-neighbor-advert } accept
# Allow SSH access on port 7777 [rate limit]
tcp dport 7777 ct state new limit rate 3/minute accept
# Allow HTTP / HTTPS traffic
tcp dport { http, https } accept
# Reject other packets
ip protocol tcp reject with tcp reset
ip6 nexthdr tcp reject with tcp reset
}
####################
# Forward Traffic #
####################
chain forward {
type filter hook forward priority 0; policy drop;
}
####################
# Outgoing Traffic #
####################
chain output {
type filter hook output priority 0; policy accept;
# Allow loopback interface
oifname lo accept
}
}
Esto me lleva a otra pregunta: ¿qué hacer?