I have:
- a Spring Boot application running on Windows on 8080 and
- a service running in the Docker container within the WSL2 Ubuntu, and
I'm loking how to enable the Windows host's 8080 to this service?
The limitation is that the service is part of the development setup and is built with the docker-compose, so the solution should be IP-independent or fully (maximally) automated.
The application is reachable with curl $(hostname).local:8080
, but when I try to add iptables
rules (based on those found here) to redirect "wsl:8080->winhost:8080":
sudo iptables -A FORWARD -i lo -o eth0 -p tcp --syn --dport 8080 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -i lo -o eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o lo -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -A PREROUTING -i lo -p tcp --dport 8080 -j DNAT --to-destination 172.28.80.1:8080
sudo iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 8080 -d 172.28.80.1 -j SNAT --to-source 127.0.0.1:8080
where 172.28.80.1
- is the Windows host IP, then curl
starts hanging until timeout.
Any suggestions?