The service 2 exposes /service1/users/:id in this exposure I make a subquery to service1 with axios /service1/users/:id and I go through traefik.
But I get an error 500. The service1 does not receive the request.
Server2
app.get("/server2/users/:id", function(req, res) {
axios.get("http://server_1.localhost/server1/users/2").then( (response) => {
res.json(response);
})
});
app.listen(3002);
Mon server 1
app.get("/server1/users/:id", function(req, res) {
res.send({
name: "test",
lastName: "test",
rule: "User",
});
});
I used docker so this my docker-compose file. But I get an error 500. The service1 does not receive the request. But I get an error 500. The service1 does not receive the request.
version: "3"
services:
reverse-proxy:
image: traefik:v2.8
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=true"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
#- ./traefik.toml:/traefik.toml
networks:
- webgateway
server_1:
build: ./server_1
ports:
- "3001:3001"
labels:
- "traefik.docker.network=traefik"
- "traefik.backend=server_1"
- "traefik.frontend.rule=Host:server_1.localhost"
- "traefik.http.routers.server_1.rule=Host(`server_1.localhost`)"
- "traefik.http.routers.server_1.entrypoints=web"
- "traefik.port=3001"
networks:
- webgateway
server_2:
build: ./server_2
ports:
- "3002:3002"
labels:
- "traefik.docker.network=traefik"
- "traefik.backend=server_2"
- "traefik.frontend.rule=Host:server_2.localhost"
- "traefik.http.routers.server_2.rule=Host(`server_2.localhost`)"
- "traefik.http.routers.server_2.entrypoints=web"
- "traefik.port=3002"
networks:
- webgateway
networks:
webgateway:
driver: bridge