Random Proxy Issues

The reason is simple. Spammers send multiple links so new users can’t post more than two links. In your case, you don’t even need links just URLs which should be shared in code blocks or just as an inline code. You can find the formatting guide here: How to format your forum posts

Now back to your issue.

It is because what you are trying to do is really unusual and if you know how Docker and Docker Desktop works you will understand it why. So I @meyay was probably lost in your configuration and forgot that in indeed you can have an aplication listening on localhost and connect to it from Docker Desktop. It wouldn’t be true in case of Docker Engine which is running inside Docker Desktop too.

I have no idea what that random connection is caused by, but it is true, that the traffic is going through multiple layers and the problem could be anywhere or a mix of multiple steps not working well together.

This is what is happening (not 100% accurate):

  • Request goes to your host machine to the forwarded port 80
  • Port 80 from the host is forwarded to the virtual machine’s port 80
  • Port 80 from the virtual machine is forwarded to the containerd container in which the docker daemon is running
  • Poer 80 is forwarded to the Apache container port
  • Apache sends the request to the to host.docker.internal, which is not directly your localhost on Windows. It couldn’t be.
  • So the traffic goes through the container networks again to a service that probably forwards the request to a service running on your host machine
  • That service forwards the request to your localhost on Windows
  • The application running on localhost on Windows sends the response back to Apache HTTPD so it goes through the whole network path again (or maybe routed differently, I’m not sure)
  • Apache gets the response and sends it back to you.
  • Oh wait… but Apache is in the vitual machine running in a Docker container which is running in a containerd container so the response goes through the container networks and the virtual machine right back to you.

Let’s add the fact that you use Windows and probably the WSL backend. WSL distributions are containers as well. So WSL2 VM, WSL2 distro container, containerd, Docker and so on.

Now how could tell where tha traffic is lost?

If you run everything on the host, there is no vitual machine, no multiple container networks and the traffic goes immediately from you to Apache, from Apache to the apps, from the pps to Apache and from Apache back to you.

If you run everything in containers, the traffic goes through the VM and container networks once, then from Apache to the apps, from the apps to Apache and from apache through the container networks and the VM back to you.

So at least no problem between Apache and the applications.

So you don’t really use anything that containers are for except that you can use a Linux based Apache httpd and install relatively easily. You could just run Apache httpd on Windows too or run the node apps in containers so you can isolate those too.

So unfortunately it is hard to tell what is the problem with the network and where sinc we have never tried a setup like you and the network communication is complex.

Maybe it’s a timeout somewhere, maybe it is the size of the packages (MTU setting), maybe it is something with the routing if it is not always the same, but I don’t know. And we don’t use Windows usually so if it has anything to do with Windows specifically, I know even less. I know some things about the networking of Docker Desktop but not perfectly. So you need help with almost the only thing (in your specific case) we are not sure about either.