Hello,
We have a docker swarm running on multiple nodes, using Traefik for service discovery and SSL termination. It is currently hosting a bunch of web applications that are just meant to be accessible from our internal network - not exposed to the public internet.
Everything works fine.
But now we want to also host some external (public internet) facing apps on the same swarm.
We would prefer to do this using multiple entrypoints rather than using middlewares to IP whitelist the internal apps. In other words, each entrypoint would be bound to a specific IP address, and one of those IP addresses would be open to the public internet.
I am running into a problem specifying specific IP addresses in my entrypoint definitions.
For example - right now I am just testing on my local Mac which has 2 (internal) IP addresses on the same interface: 192.168.0.51 and 192.168.0.87.
Defining entrypoints with a specific IP address, as documented here is not working:
- --entrypoints.web.address=192.168.0.51:80
- --entrypoints.web-secured.address=192.168.0.51:443
This gives me an error in the traefik logs:
traefik_traefik.1.pfvlfgylsf51@docker-desktop | 2022/11/03 22:51:15 traefik.go:80: command traefik error: error while building entryPoint web: error preparing server: error opening listener: listen tcp 192.168.0.51:80: bind: cannot assign requested address
...
traefik_traefik.1.og710hgdnwx5@docker-desktop | 2022/11/03 22:51:07 traefik.go:80: command traefik error: error while building entryPoint web-secured: error preparing server: error opening listener: listen tcp 192.168.0.51:443: bind: cannot assign requested address
Same thing if I use the other IP. The only address that I can plug into the entrypoint definitions is 0.0.0.0
which of course defeats the purpose as it listens on all IPs on the system.
By the way, we are using host mode networking:
ports:
- mode: host
protocol: tcp
published: 80
target: 80
- mode: host
protocol: tcp
published: 443
target: 443
...so traefik should be able to see actual IP addresses out in the real world.
I tried the same thing with a swarm cluster that I spun up in AWS. It won't bind to the private IPv4 address of the swarm manager instance, same error as above.
I should add that in my traefik config I have:
deploy:
placement:
# traefik can only run on swarm manager nodes.
constraints: [node.role == manager]
and on both my Mac and my test AWS cluster, there is only one manager node, so Traefik is definitely running on the host that has the IP addresses that I am trying to specify.
Nothing else is running on ports 80 and 443. If I remove the IP address from the entrypoint definitions, Traefik starts up fine.
How can I get Traefik to listen on a specific IP? And really, what I ultimately want is to have 4 entrypoints (2 for http and 2 for https) with 2 each listening on a different IP.
Thanks in advance.
EDIT: I wonder if this has something to do with Docker networking?
In that case I should share my networking config.
Currently I am using a docker network called proxy
which has scope swarm
and driver overlay
.
And by "using," I mean my traefik config has the following:
...
command:
...
- --providers.docker=true
- --providers.docker.swarmMode=true
- --providers.docker.network=proxy
...
networks:
- proxy
...
networks:
proxy:
external: true
I have tried using various other types of networks but none of them seem to solve this issue.