API Gateway utilizes Traefik reverse proxy to route specific domains / subdomains to MODAPTO components.
It provides load balancing and firewall rules to enable or forbid specific communication from outside services. It secures the HTTP communication via HTTPS protocol.
Clone the repository:
git clone https://github.com/Modapto/api-gateway.git
cd api-gateway
-
Install or make sure Docker is running
-
Create a hashed password for a specific user and update the traefik_dynamic.toml file under the config folder with the following:
# Generate a hashed password using htpasswd htpasswd -nb [user] [password] # Copy the generated password and configure the dynamic config [hostPath] = URL of the Traefic Dashboard (if enabled) [user]:[hashedPassword] = Copy the contents of the generated hashed value # Configure your email on traefik.toml [email]: Your personal email
-
Deploy API Gateway from Docker Compose:
docker compose up -d
-
After some time Traefik dashboard will be available on:
https://[hostPath]
. -
To terminate Docker compose simply run:
docker compose down
For each new component that will de deployed through API Gateway we must define the following labels in each docker compose configuration:
- traefik.enable=true
- traefik.http.routers.[containerName]=true
- traefik.http.routers.[containerName].rule=Host(`[desiredURLPath]`)
- traefik.http.routers.[containerName].tls=true
- traefik.http.routers.[containerName].tls.certresolver=lets-encrypt
- traefik.http.middlewares.securityHeader.headers.sslredirect=true
- traefik.http.routers.[containerName].middlewares=securityHeader
- traefik.http.services.notification-center.loadbalancer.server.port=[containerPort]
# Optionally we can configure a PathPrefix in the Host Role
- traefik.http.routers.[containerName].rule=Host(`[desiredURLPath]`) && PathPrexix(`[desiredPathPreix]`)
This project has received funding from the European Union's Horizon 2022 research and innovation programm, under Grant Agreement 101091996.
For more details about the licence, see the LICENSE file.
- Alkis Aznavouridis ([email protected])