-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dbohdan/master
This improves several things: * example.com/path/foo.md redirects to github; * Indices work in subdirs; * You can serve plain HTML pages, too; * Missing files return error 404, not 500; * You can have a favicon.ico.
- Loading branch information
Showing
2 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,60 @@ | ||
# Based on https://github.com/dbohdan/caddy-markdown-site | ||
|
||
# 1. install caddy_2.4.3_linux_amd64.deb from https://github.com/caddyserver/caddy/releases/tag/v2.4.3 | ||
# 2. overwrite /etc/caddy/Caddyfile with this file | ||
# 3. sudo systemctl restart caddy | ||
# 4. make sure /home/shawn/website is readable by anyone | ||
|
||
#http://blog.gpt4.org { | ||
:80 { | ||
root * /home/shawn/website | ||
|
||
encode gzip | ||
|
||
file_server | ||
templates | ||
|
||
@page not path /media/* | ||
templates @page | ||
rewrite @page /templates/index.html | ||
@media { | ||
path /favicon.ico | ||
path /media/* | ||
} | ||
@markdown { | ||
file | ||
path_regexp \.md$ | ||
} | ||
@markdown_exists { | ||
file {path}.md | ||
} | ||
|
||
encode gzip | ||
handle @media { | ||
file_server | ||
} | ||
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 { | ||
rewrite * /templates/error.html | ||
|
||
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters