Skip to content

Commit

Permalink
switch to traefik
Browse files Browse the repository at this point in the history
  • Loading branch information
khanzadimahdi committed Jan 7, 2025
1 parent 24c1572 commit 7d53857
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 62 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/infrastructure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v4

- name: Terraform validate and apply
uses: ./.github/actions/terraform
uses: ../.github/actions/terraform
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -31,7 +31,7 @@ jobs:
apply: true

- name: Build image
uses: ./.github/actions/docker-build
uses: ../.github/actions/docker-build
with:
context: ./proxy
dockerfile: ./proxy/Dockerfile
Expand All @@ -56,7 +56,7 @@ jobs:
uses: actions/checkout@v4

- name: Build and push proxy image
uses: ./.github/actions/docker-build
uses: ../.github/actions/docker-build
with:
context: ./proxy
dockerfile: ./proxy/Dockerfile
Expand All @@ -79,7 +79,7 @@ jobs:

steps:
- name: Terraform validate and apply
uses: ./.github/actions/terraform
uses: ../.github/actions/terraform
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
4 changes: 2 additions & 2 deletions proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM nginx:1.26-alpine
FROM traefik:v3.3

COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY ./traefik.yml /etc/traefik/traefik.yml

EXPOSE 80
56 changes: 0 additions & 56 deletions proxy/nginx.conf

This file was deleted.

70 changes: 70 additions & 0 deletions proxy/traefik.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
http:
routers:
# Catch-all router for unmatched subdomains
catch-all:
rule: "HostRegexp(`{subdomain:[a-z0-9-]+}.*`)"
entryPoints:
- web
service: frontend-service
middlewares:
- headers

# Backend subdomain
backend:
rule: "Host(`backend.{subdomain:[a-z0-9-]+}.*`)"
entryPoints:
- web
service: app-service
middlewares:
- headers

# Docker Dashboard subdomain
dockerdashboard:
rule: "Host(`dockerdashboard.{subdomain:[a-z0-9-]+}.*`)"
entryPoints:
- web
service: docker-dashboard-service
middlewares:
- headers

# MongoDB Dashboard subdomain
mongodashboard:
rule: "Host(`mongodashboard.{subdomain:[a-z0-9-]+}.*`)"
entryPoints:
- web
service: mongodb-dashboard-service
middlewares:
- headers

services:
frontend-service:
loadBalancer:
servers:
- url: "http://frontend:3000"

app-service:
loadBalancer:
servers:
- url: "http://app:80"

docker-dashboard-service:
loadBalancer:
servers:
- url: "http://docker_dashboard:9000"

mongodb-dashboard-service:
loadBalancer:
servers:
- url: "http://mongodb_dashboard:8081"

middlewares:
headers:
headers:
customRequestHeaders:
X-Real-IP: "{remote_ip}"
X-Forwarded-For: "{remote_ip}"
X-Forwarded-Proto: "{scheme}"

entryPoints:
web:
address: ":80"

0 comments on commit 7d53857

Please sign in to comment.