Add Caddy HTTP error files
This commit is contained in:
parent
abd49debb7
commit
1755c05428
22
Caddyfile
22
Caddyfile
|
@ -2,8 +2,26 @@ emacssurvey.tecosaur.net
|
||||||
|
|
||||||
@dynamic {
|
@dynamic {
|
||||||
not path /css/*
|
not path /css/*
|
||||||
|
not path /favicon.ico
|
||||||
|
not path /robots.txt
|
||||||
}
|
}
|
||||||
reverse_proxy @dynamic localhost:8000
|
reverse_proxy @dynamic localhost:8000
|
||||||
|
|
||||||
root /css/* /opt/emacs-survey/public/css/
|
root * /opt/emacs-survey/public
|
||||||
file_server /css/style.css
|
file_server
|
||||||
|
|
||||||
|
handle_errors {
|
||||||
|
@404 expression `{err.status_code} == 404`
|
||||||
|
handle @404 {
|
||||||
|
rewrite * /caddy-error.html
|
||||||
|
templates
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
handle {
|
||||||
|
rewrite * /{err.status_code}
|
||||||
|
reverse_proxy https://http.cat {
|
||||||
|
header_up Host {upstream_hostport}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
35
setup.org
35
setup.org
|
@ -72,22 +72,51 @@ SETUPDIR=$(dirname "$(readlink --canonicalize-existing "$0")")
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Caddy Config
|
** Caddy Config
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args:prog: :tangle Caddyfile
|
||||||
|
:END:
|
||||||
|
|
||||||
We just need to redirect to Genie for now, which makes for a rather simple
|
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
|
config. The only complication is serving the static files through Caddy not
|
||||||
Genie, for performance reasons (Genie recommends against serving static files
|
Genie, for performance reasons (Genie recommends against serving static files
|
||||||
with it).
|
with it).
|
||||||
|
|
||||||
#+begin_src prog :tangle Caddyfile
|
#+begin_src prog
|
||||||
emacssurvey.tecosaur.net
|
emacssurvey.tecosaur.net
|
||||||
|
|
||||||
@dynamic {
|
@dynamic {
|
||||||
not path /css/*
|
not path /css/*
|
||||||
|
not path /favicon.ico
|
||||||
|
not path /robots.txt
|
||||||
}
|
}
|
||||||
reverse_proxy @dynamic localhost:8000
|
reverse_proxy @dynamic localhost:8000
|
||||||
|
#+end_src
|
||||||
|
|
||||||
root /css/* /opt/emacs-survey/public/css/
|
We'll just pass all other requests to the public folder of the Emacs Survey.
|
||||||
file_server /css/style.css
|
#+begin_src prog
|
||||||
|
root * /opt/emacs-survey/public
|
||||||
|
file_server
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
The only thing left is error pages, for which we'll use a combination of error
|
||||||
|
pages and http.cat 🐱.
|
||||||
|
|
||||||
|
#+begin_src prog
|
||||||
|
handle_errors {
|
||||||
|
@404 expression `{err.status_code} == 404`
|
||||||
|
handle @404 {
|
||||||
|
rewrite * /caddy-error.html
|
||||||
|
templates
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
handle {
|
||||||
|
rewrite * /{err.status_code}
|
||||||
|
reverse_proxy https://http.cat {
|
||||||
|
header_up Host {upstream_hostport}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Just this one file is all it takes to get Caddy set up to our liking 🙂.
|
Just this one file is all it takes to get Caddy set up to our liking 🙂.
|
||||||
|
|
Loading…
Reference in New Issue