changelog shortlog graph tags branches files raw help

Mercurial > infra > etc / changeset: update caddyfile

changeset 6: 9e1a84aa4ede
parent 5: 05cbbcd63fa6
child 7: faec9ab70733
author: Richard Westhaver <ellis@rwest.io>
date: Wed, 12 Jun 2024 14:33:30 -0400
files: caddy/Caddyfile
description: update caddyfile
     1.1--- a/caddy/Caddyfile	Wed Jun 12 14:31:33 2024 -0400
     1.2+++ b/caddy/Caddyfile	Wed Jun 12 14:33:30 2024 -0400
     1.3@@ -9,32 +9,113 @@
     1.4 # domain name.
     1.5 #
     1.6 # https://caddyserver.com/docs/caddyfile/concepts#addresses
     1.7+{
     1.8+  admin :2020
     1.9+  email ellis@rwest.io
    1.10+  servers {
    1.11+    enable_full_duplex
    1.12+  }
    1.13+  order webdav before file_server
    1.14+}
    1.15 
    1.16-{
    1.17-	# Restrict the admin interface to a local unix file socket whose directory
    1.18-	# is restricted to caddy:caddy. By default the TCP socket allows arbitrary
    1.19-	# modification for any process and user that has access to the local
    1.20-	# interface. If admin over TCP is turned on one should make sure
    1.21-	# implications are well understood.
    1.22-	admin "unix//run/caddy/admin.socket"
    1.23+(logging) {
    1.24+	log {
    1.25+		output file /var/log/caddy.log
    1.26+		format json
    1.27+	}
    1.28+}
    1.29+
    1.30+(cors-origin) {
    1.31+    @match-cors-preflight-{args.0} {
    1.32+        header Origin "{args.0}"
    1.33+        method OPTIONS
    1.34+    }
    1.35+    handle @match-cors-preflight-{args.0} {
    1.36+        header {
    1.37+            Access-Control-Allow-Origin "{args.0}"
    1.38+            Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
    1.39+            Access-Control-Allow-Headers *
    1.40+            Access-Control-Max-Age "3600"
    1.41+            defer
    1.42+        }
    1.43+        respond "" 204
    1.44+    }
    1.45+
    1.46+    @match-cors-request-{args.0} {
    1.47+        header Origin "{args.0}"
    1.48+        not method OPTIONS
    1.49+    }
    1.50+    handle @match-cors-request-{args.0} {
    1.51+        header {
    1.52+            Access-Control-Allow-Origin "{http.request.header.origin}"
    1.53+            Access-Control-Expose-Headers *
    1.54+            defer
    1.55+        }
    1.56+    }
    1.57 }
    1.58 
    1.59 http:// {
    1.60 	# Set this path to your site's directory.
    1.61-	root * /usr/share/caddy
    1.62+	root * /srv/http/
    1.63+        file_server browse
    1.64+}
    1.65 
    1.66-	# Enable the static file server.
    1.67-	file_server
    1.68 
    1.69-	# Another common task is to set up a reverse proxy:
    1.70-	# reverse_proxy localhost:8080
    1.71-
    1.72-	# Or serve a PHP site through php-fpm:
    1.73-	# php_fastcgi localhost:9000
    1.74-
    1.75-	# Refer to the directive documentation for more options.
    1.76-	# https://caddyserver.com/docs/caddyfile/directives
    1.77+compiler.company {
    1.78+  import cors-origin https://cdn.compiler.company
    1.79+  root * /srv/http/compiler.company
    1.80+  handle {
    1.81+    try_files {path} {path.html} {path}/
    1.82+    file_server
    1.83+  }
    1.84+}
    1.85+# chat.compiler.company
    1.86+cdn.compiler.company {
    1.87+  @get method GET
    1.88+  import cors-origin *
    1.89+  import logging
    1.90+  root * /srv/http/cdn.compiler.company
    1.91+  route {
    1.92+    file_server @get browse
    1.93+    webdav
    1.94+  }
    1.95 }
    1.96 
    1.97-# Import additional caddy config files in /etc/caddy/conf.d/
    1.98-import /etc/caddy/conf.d/*
    1.99+the.compiler.company {
   1.100+  import cors-origin https://cdn.compiler.company
   1.101+  root * /srv/http/the.compiler.company
   1.102+  handle {
   1.103+    try_files {path}{path}.html {path}/
   1.104+    file_server
   1.105+  }
   1.106+}
   1.107+
   1.108+demo.compiler.company {
   1.109+  import cors-origin https://cdn.compiler.company
   1.110+  root * /srv/http/demo.compiler.company
   1.111+  # reverse_proxy
   1.112+}
   1.113+
   1.114+packy.compiler.company {
   1.115+  @get method GET
   1.116+  import cors-origin https://packy.compiler.company
   1.117+  import logging
   1.118+  root * /srv/http/packy.compiler.company
   1.119+  route {
   1.120+    file_server @get browse
   1.121+    webdav
   1.122+  }
   1.123+}
   1.124+
   1.125+hg.compiler.company {
   1.126+  import cors-origin https://packy.compiler.company
   1.127+  import cors-origin https://cdn.compiler.company
   1.128+  import cors-origin https://vc..compiler.company
   1.129+  import logging
   1.130+  root * /home/vc
   1.131+  reverse_proxy localhost:8888
   1.132+}
   1.133+# nas-t.net
   1.134+# otom8.dev
   1.135+# rwest.io
   1.136+# c2.rwest.io