-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCaddyfile
78 lines (66 loc) · 1.82 KB
/
Caddyfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Based on https://github.com/dbohdan/caddy-markdown-site
# - git clone https://github.com/shawwn/website ~/website
# - cd ~/website
# 1. install caddy_2.4.3_linux_amd64.deb from https://github.com/caddyserver/caddy/releases/tag/v2.4.3:
# - wget https://github.com/caddyserver/caddy/releases/download/v2.4.3/caddy_2.4.3_linux_amd64.deb
# - sudo dpkg -i caddy_2.4.3_linux_amd64.deb
# 2. run the blog:
# - sudo systemctl stop caddy
# - sudo caddy run -watch
# If you want automatic deployment, run this in a separate tmux pane:
#
# watch -n 10 'git fetch ; git reset --hard origin/$(git symbolic-ref --short HEAD) ; git pull'
:80 {
root * .
encode gzip
file_server
templates
redir / /index 302
@media {
path /favicon.ico
path /media/*
}
@templates {
path /templates/*
not path /templates/*.css /templates/*.js
}
@markdown {
file
path_regexp \.md$
}
@markdown_exists {
file {path}.md
}
handle @media {
file_server
}
handle @templates {
error 403
}
handle @markdown {
redir * https://github.com/shawwn/website/blob/master{path}
}
handle @markdown_exists {
map {path} {caddy_markdown_site.append_to_path} {
default extension
}
rewrite * /templates/index.html
}
handle_errors {
file_server
templates
@markdown_index_exists {
file {path}/index.md
expression `{http.error.status_code} == 404`
}
handle @markdown_index_exists {
map {path} {caddy_markdown_site.append_to_path} {
default index
}
rewrite @markdown_index_exists /templates/index.html
}
handle {
rewrite * /templates/error.html
}
}
}