Score:0

Redirect 127.0.0.1:80, 127.0.0.1:443 and 127.0.0.1:8080 to an Hyper-V virtual machine

ph flag

Alright so the title may be a little misleading but that's the best I could find.

Here is what I am trying to accomplish:

I am on Windows 11 Pro. I have a virtual machine running Debian 11 on Hyper-V. This machine is running a Docker environment using Traefik as a reverse proxy.

I am developer working on various web projects. I have been trying for some time to set up Traefik as a reverse proxy so I can easily run multiple projects at once on different subdomains redirected locally.

Traefik seems to be working just fine, so this is probably not my issue. Basically, my virtual machine has the IP 172.19.233.121.

I own a domain that I redirected (A) to 127.0.0.1. This was the only real way I could find to make Traefik behave properly with HSTS. Without this, it was unable to properly get certificates from LetsEncrypt and everything was broken.

Now, when I access 172.19.233.121, I reach Traefik, which is great. However, when I call my domain, I do not reach Traefik, as my domain is mapped to 127.0.0.1 and my virtual machine has the 172.19.233.121 IP.

I could redirect my domain (A) to 172.19.233.121 but this is undesirable as I do not possess that IP and it may get attributed to anything in the future. I do not wish this domain to point to something that may become reachable.

My question is: How can I make my domain - which is currently redirecting to 127.0.0.1 - reach my virtual machine which has the IP 172.19.233.121?

I did think about using Windows netsh and ran the following PowerShell command:

netsh interface portproxy add v4tov4 listenport=8080 listenaddress=127.0.0.1 connectport=8080 connectaddress=172.19.233.121

While the command ran just fine, it did not work as I intended it to. Instead of telling me it couldn't reach 127.0.0.1, it simply hanged until it finally timed out.

I removed this netsh interface as it may create problems.

Honestly, I'm not entirely sure what I am doing, so maybe all of this will sound completely crazy to you guys. If you guys have a better solutions that would be simpler and probably cleaner, I'm totally up for it!

I admit I am stuck as I have no real idea how to solve this.

Please, send help! <3

Ron Maupin avatar
us flag
Any packets sent to an address in the `127.0.0.0/8` range will immediately loop back inside the host sending the packets. Your VM is a separate host with its own `127.0.0.0/8` loopback network, so when it sends packets to an address in that range, the packets loop back inside the VM.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.