Compare commits

...

2 Commits

Author SHA1 Message Date
TEC 5bf5186599
Add HTTP error redirection to CADDY 2022-10-17 01:04:02 +08:00
TEC 66eac8831b
Improve static file matching 2022-10-17 01:03:15 +08:00
2 changed files with 34 additions and 5 deletions

View File

@ -2,8 +2,17 @@ emacssurvey.tecosaur.net
@dynamic {
not path /css/*
not path /favicon.ico
not path /robots.txt
}
reverse_proxy @dynamic localhost:8000
root /css/* /opt/emacs-survey/public/css/
file_server /css/style.css
root * /opt/emacs-survey/public
file_server
handle_errors {
rewrite * /{err.status_code}
reverse_proxy https://http.cat {
header_up Host {upstream_hostport}
}
}

View File

@ -72,22 +72,42 @@ SETUPDIR=$(dirname "$(readlink --canonicalize-existing "$0")")
#+end_src
** Caddy Config
:PROPERTIES:
:header-args:prog: :tangle Caddyfile
:END:
We just need to redirect to Genie for now, which makes for a rather simple
config. The only complication is serving the static files through Caddy not
Genie, for performance reasons (Genie recommends against serving static files
with it).
#+begin_src prog :tangle Caddyfile
#+begin_src prog
emacssurvey.tecosaur.net
@dynamic {
not path /css/*
not path /favicon.ico
not path /robots.txt
}
reverse_proxy @dynamic localhost:8000
#+end_src
root /css/* /opt/emacs-survey/public/css/
file_server /css/style.css
We'll just pass all other requests to the public folder of the Emacs Survey.
#+begin_src prog
root * /opt/emacs-survey/public
file_server
#+end_src
For HTTP errors we could re-use the Genie error pages ... or have some fun 🐱.
#+begin_src prog
handle_errors {
rewrite * /{err.status_code}
reverse_proxy https://http.cat {
header_up Host {upstream_hostport}
}
}
#+end_src
Just this one file is all it takes to get Caddy set up to our liking 🙂.