Hi,
I am using traefik as a reverse proxy that routes HTTP requests to the according container by matching the request domain.
Let’s say I have the following containers:
- traefikContainer
- apiContainer (as
htp://api.local:80
via traefik) - frontendContainer (as
htp://frontend.local:80
via traefik)
I can access both containers via the reverse proxy from my host machine.
Now i want to send HTTP requests from frontendContainer to htp://api.local
.
This used to work a year ago with:
# frontendContainer/docker-compose.yml
services:
frontendContainer:
networks:
traefik_default:
aliases:
- api.local
But now docker exec frontendContainer ping api.local
returns 127.0.0.1
instead of traefik
s IP address.
All I want, is to send an HTTP request from frontendContainer to apiContainer via traefikContainer by addressing htp://api.local
.
How can this be achieved?
(must use htp
instead of http
to circumvent post restrictions)
UPDATE
I found a workaround:
services:
frontendContainer:
extra_hosts:
- "api.local:host-gateway"
This way, the request will be routed to the host system, from which the reverse proxy is reachable.