1

I'm running a httpd apache2 proxy in docker swarm mode with docker stack deploy.

Problem: when I access mymachine:80, the access.log only shows the remote ip of the docker ingress swarm network, like 10.0.0.2. And not the real clients' ip.

Question: how can I tell swarm to retain the original IP address (maybe write it into another IP header?), without having to force my container or ports into mode: host?

Because I don't want to use zero-downtime deployment, which is what I have in docker-swarm mode without containers in host-mode.

membersound
  • 275
  • 1
  • 5
  • 13

1 Answers1

1

In short, there's no way to achieve this within the constraints you ask.

Docker swarm uses traffic forwarding, not listening ports, to handle ingress traffic. You can see telltale signs of this with iptables -nL, and noticing that the docker firewall rules (DOCKER-USER, DOCKER-INGRESS, etc) are in the FORWARD chain, not the INPUT chain (and every so often you'll see user caught by surprise, that their ingress firewall rules aren't blocking traffic).

As you pointed out, having your port on mode: host will solve the "real IP" issue (as the listening port will be on the host's "real" network namespace), but that prevents you from doing zero-downtime deployments (because the port is then a single resource in use).