I have few microservices, let's call it food-ms
, receipt-ms
, ingredients-ms
and frontend
with React App consumes those microservices.
Each of them exposes API at /api/[methods]
.
I would like to create environment for production and development using Docker and docker-compose with next properties:
Application should be available at single host. In production host should be for example
http://food-app.test
, for development it should be (ideally) localhostEach microservice and frontend should be at single host, but at different paths. For example,
food-ms
API should be atlocalhost/food/api
,receipt-ms
API should be atlocalhost/receipt/api
etc. Frontend should be atlocalhost
root/
path.Ideally, I would like to be able to run some services outside container for easy debugging, but still be reverse proxied and available by
localhost/{service}/api
.
I found a traefik reverse proxy, and experimented with it a bit, but stuck in issues:
- How to make app available at some predictable domain, like
localhost
. Currently I'm able to proxy requests to specific backend by specifying a strange host inHost
header like<container-name>.<network-name>.docker.localhost
Seems frontends described intraefik.toml
don't have an effect. - How to route requests from one frontend to different backends depending on path?
- How to route request to an external IP and port (I would like to use this to run services outside container for debugging)? Should I use
host
network in docker for this?
Thanks in advance.
Here is my traefik.toml
defaultEntryPoints = ["http"]
[entryPoints]
[entryPoints.http]
address = ":80"
[file]
[frontends]
[frontends.food]
entrypoints = ["http"]
backend="food"
[frontends.receipts]
entrypoints = ["http"]
backend="receipts"
Those frontends seems doesn't get applied, because dashboards doesn't get changed if I commend them out.