I have a service listen on 127.0.0.1:8080, and I only want to export port 80 to outside. I tried port forwarding but no success. So how can I forward port 80 to localhost:8080?
This is what i tried:
firewall-cmd --add-port-forward=port=8080:proto=tcp:toport=80:toaddr=127.0.0.1
OS: fedora 36, firewalld
2022-07-02 update:
I tried again with this but failed:
firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080:toaddr=127.0.0.1
# firewall-cmd --list-all
FedoraServer (active)
target: default
icmp-block-inversion: no
interfaces: enp1s0
sources:
services: cockpit dhcpv6-client http https ssh
ports: 80/tcp 80/udp 443/tcp 443/udp
protocols:
forward: no
masquerade: yes
forward-ports:
port=443:proto=tcp:toport=8443:toaddr=127.0.0.1
port=443:proto=udp:toport=8443:toaddr=127.0.0.1
port=443:proto=tcp:toport=8443:toaddr=
port=443:proto=udp:toport=8443:toaddr=
port=80:proto=tcp:toport=8080:toaddr=127.0.0.1
source-ports:
icmp-blocks:
rich rules:
nc -l 127.0.0.1 8080
nc x.x.x.x 80
Ncat: TIMEOUT.
Edit 2022-07-03: fix wrong port number.
nc
example seems to suggest that you don't actually have anything listening on port 8080.