From 95856227fec933c237b68b811ba3058a0fd79500 Mon Sep 17 00:00:00 2001 From: Hoai Viet Nguyen <viet.nguyen@th-koeln.de> Date: Fri, 28 Feb 2025 23:25:16 +0100 Subject: [PATCH] add reverse proxy --- caddy/Caddyfile | 23 +++++++++++++++++++++++ caddy/Dockerfile | 2 ++ docker-compose.yml | 12 +++++------- 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 caddy/Caddyfile create mode 100644 caddy/Dockerfile diff --git a/caddy/Caddyfile b/caddy/Caddyfile new file mode 100644 index 0000000..42c9a6c --- /dev/null +++ b/caddy/Caddyfile @@ -0,0 +1,23 @@ +:80 { + # http://localhost:9001/nginx -> http://nginx/nginx + # reverse_proxy /nginx nginx + # http://localhost:9001/nginx -> http://nginx/ + route /nginx* { + uri replace /nginx / + reverse_proxy nginx + } + + route /apache* { + uri replace /apache / + reverse_proxy apache + } + + route /todolist* { + uri replace /todolist / + reverse_proxy todolist:8080 + } +} + +todolist.org:80 { + reverse_proxy todolist:8080 +} diff --git a/caddy/Dockerfile b/caddy/Dockerfile new file mode 100644 index 0000000..399e907 --- /dev/null +++ b/caddy/Dockerfile @@ -0,0 +1,2 @@ +FROM caddy:2.9.1 +COPY Caddyfile /etc/caddy/Caddyfile \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b9a3bbd..ad2424c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,16 @@ #Auflistung aller Dienste services: + caddy: + build: ./caddy + ports: + - 9001:80 #Dienstname bzw. Hostname innerhalb des Netzwerks nginx: #Pfad zum Dockerfile für diesen Container build: ./nginx #Port-Mapping von außen nach innen - ports: - - 8080:80 apache: #Basis-Image image: httpd:2.4 - ports: - - 207:80 todolist: - build: ./todolist_spring - ports: - - 8070:8080 \ No newline at end of file + build: ./todolist_spring \ No newline at end of file -- GitLab