I'm trying to use Traefik on Docker as an internal reverse-proxy for a container, but no matter what I try, it keeps exposing that container to the Internet.
I want 1 router to expose it internally, and 1 for the Internet. The Internet one works well.
I have a container A that must call another container B on port 80/443, but B only exposes port 2000.
Since A and B are on the same machine, I don't want to expose B on the Internet.
My idea is: A calls http://b.lan, Traefik catches it through a label on B, and passes the traffic to B port 2000.
Everytime I try to use a label on B, it gets exposed to the Internet.
Is there anyway to prevent this ?
PS: I have also tried to whitelist my LAN, but Traefik can only whitelist based on X-Forwarded-For and surprisingly doesn't provide that header on response and neither does B so no luck there.
Has anyone gone through this situation before and found a way ? Please tell me I'm getting desperate
Hello @asterix, thanks for replying
It seems that you put them on 2 different networks, and traefik can't redirect traffic to db.
Maybe I wasn't clear enough on what I want to do, so I will use your example to make it simpler.
Let's define container abc along with traefik and db. db only has 3306 as an internal port.
So if you want to reach db from lan, you must call http://db:3306.
The problem is that abc can only call containers on port 80 (i.e. abc must call http://db or http://db.mysite.com). I don't want to mess with the source code of abc so I need to respect this constraint.
I could add
ports:
- "80:3306"
to db but port 80 is already exposed by traefik, so no.
Therefore, what I'm trying to do is:
abc calls http://db.mysite.com
traefik catches it
redirects to db:3306
But I don't want db.mysite.com to be on the Internet.
Ideally, I want this to work
If set to true , specifies that this network has been created outside of Compose. docker-compose up does not attempt to create it, and raises an error if it doesn’t exist.