I'm having a podman container running rootless on port 8080 and 8443. But I want to have access to them on port 80 and 443.
This is working quite well with firewalld and this command:
firewall-cmd \
--add-rich-rule "rule family=ipv4 forward-port port=80 protocol=tcp to-port=8080" \
--add-rich-rule "rule family=ipv6 forward-port port=80 protocol=tcp to-port=8080" \
--add-rich-rule "rule family=ipv4 forward-port port=443 protocol=tcp to-port=8443" \
--add-rich-rule "rule family=ipv6 forward-port port=443 protocol=tcp to-port=8443" \
--add-rich-rule "rule family=ipv4 forward-port port=443 protocol=udp to-port=8443" \
--add-rich-rule "rule family=ipv6 forward-port port=443 protocol=udp to-port=8443"
firewall-cmd --add-masquerade
But I don't see the correct source IP within the container, it's always the IP of the container itself. I tried also with iptables rules:
firewall-cmd --direct --add-rule ipv4 nat PREROUTING 0 -p tcp --dport 80 -j REDIRECT --to-ports 8080
firewall-cmd --direct --add-rule ipv4 nat POSTROUTING 0 -p tcp --dport 8080 -j MASQUERADE