From b2e7987dc06152ca48d145055af39c5525baf8c7 Mon Sep 17 00:00:00 2001 From: Kar l5 Date: Sat, 27 Apr 2024 21:37:34 +0530 Subject: [PATCH] caddy --- caddy/Caddyfile | 30 ++++++++ caddy/config-sample.json | 145 +++++++++++++++++++++++++++++++++++++++ caddy/run.txt | 3 + 3 files changed, 178 insertions(+) create mode 100644 caddy/Caddyfile create mode 100644 caddy/config-sample.json create mode 100644 caddy/run.txt diff --git a/caddy/Caddyfile b/caddy/Caddyfile new file mode 100644 index 0000000..b95f6aa --- /dev/null +++ b/caddy/Caddyfile @@ -0,0 +1,30 @@ +http://code.internal:8080 { +# Could be another domain/IP as well +reverse_proxy { +to localhost:8081 +} +} + +http://stage.internal:8080 { +# Could be another domain/IP as well +reverse_proxy 127.0.0.1:8082 +} + +http://dev.internal:8080 { +# Proxy with a DNS Server name instead +reverse_proxy internal-site:8083 +} + +test.domains.siliconpin.com { +# Could be another domain/IP as well +reverse_proxy :9002 +} + +http://web.internal:8080 { + handle /code/* { + # Could be another domain/IP as well + reverse_proxy { + to localhost:8081 + } + } +} diff --git a/caddy/config-sample.json b/caddy/config-sample.json new file mode 100644 index 0000000..30a8a8f --- /dev/null +++ b/caddy/config-sample.json @@ -0,0 +1,145 @@ +{ + "apps": { + "http": { + "servers": { + "srv0": { + "listen": [ + ":443" + ], + "routes": [ + { + "handle": [ + { + "handler": "subroute", + "routes": [ + { + "handle": [ + { + "handler": "reverse_proxy", + "upstreams": [ + { + "dial": ":9002" + } + ] + } + ] + } + ] + } + ], + "match": [ + { + "host": [ + "ns61.siliconpin.com" + ] + } + ], + "terminal": true + } + ] + }, + "srv1": { + "automatic_https": { + "skip": [ + "stage.internal", + "code.internal", + "dev.internal" + ] + }, + "listen": [ + ":8080" + ], + "routes": [ + { + "handle": [ + { + "handler": "subroute", + "routes": [ + { + "handle": [ + { + "handler": "reverse_proxy", + "upstreams": [ + { + "dial": "127.0.0.1:8082" + } + ] + } + ] + } + ] + } + ], + "match": [ + { + "host": [ + "stage.internal" + ] + } + ], + "terminal": true + }, + { + "handle": [ + { + "handler": "subroute", + "routes": [ + { + "handle": [ + { + "handler": "reverse_proxy", + "upstreams": [ + { + "dial": "localhost:8081" + } + ] + } + ] + } + ] + } + ], + "match": [ + { + "host": [ + "code.internal" + ] + } + ], + "terminal": true + }, + { + "handle": [ + { + "handler": "subroute", + "routes": [ + { + "handle": [ + { + "handler": "reverse_proxy", + "upstreams": [ + { + "dial": "internal-site:8083" + } + ] + } + ] + } + ] + } + ], + "match": [ + { + "host": [ + "dev.internal" + ] + } + ], + "terminal": true + } + ] + } + } + } + } +} diff --git a/caddy/run.txt b/caddy/run.txt new file mode 100644 index 0000000..924bf27 --- /dev/null +++ b/caddy/run.txt @@ -0,0 +1,3 @@ +docker run -itd --name caddy --net host --restart unless-stopped -v ~/docker/data/caddy/Caddyfile:/etc/caddy/Caddyfile -v ~/docker/data/caddy/srv:/srv -v ~/docker/data/caddy/caddy_data:/data -v ~/docker/data/caddy/caddy_config:/config caddy + +curl "http://localhost:2019/config/" | jq