Caddy file server

This commit is contained in:
Daniel Flanagan 2022-11-22 14:35:47 -06:00
parent d91339501f
commit 6912c4bdd0
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
4 changed files with 57 additions and 15 deletions

View file

@ -8,4 +8,13 @@ http:// {
browse /etc/caddy/browse_template.html
hide \.*
}
templates
handle_errors {
@404 {
expression {http.error.status_code} == 404
}
rewrite @404 /404.html
}
}

View file

@ -1,18 +1,19 @@
#!/usr/bin/env fish
pushd (dirname (status -f))
set dfp $argv[1]
set homedir $argv[2]
set xdgconfdir $argv[3]
# set dfp $argv[1]
# set homedir $argv[2]
# set xdgconfdir $argv[3]
set layerdir (pwd)
function _p
set source $argv[1]
set dest $argv[2]
sudo rm -rf "$dest"
echo "Copying $source to $dest"
sudo cp -r "$source" "$dest"
echo Copying $argv[1..-2] to $argv[-1]
sudo cp -r $argv[1..-2] $argv[-1]
end
sudo rm -rf /etc/caddy
_p $layerdir/caddy /etc/caddy
_p $layerdir/webserver-root /srv/http
sudo mkdir -p /srv/http
sudo chmod 755 /srv/http
_p $layerdir/webserver-root/* /srv/http

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://lyte.dev/styles.css" />
<title>404 Not Found</title>
</head>
<body>
<main>
<p>404 - File Not Found 😢</p>
<p><a href="/">Go to Index</a></p>
</main>
</body>
</html>

View file

@ -1,6 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>Public Web lyte.dev Machine</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://lyte.dev/styles.css" />
<title>{{ .Host }} - Index</title>
</head>
<body>
<a href="./public-files/">Public Files</a>
<main>
<p>Welcome to <code><a href="/">The Index</a></code> at <code><a href="//{{ .Host }}">{{ .Host }}</a></code></p>
<p>
If you wandered here by accident, you are either lost and <a href="https://lyte.dev">in need of context</a>, are <a href="./public-files">looking for a particular file</a>, or are just exploring.
</p>
<p>Whatever your adventure, welcome!</p>
<p><a href="/public-files">View <code>{{ .Host }}</code> Public Files</a></p>
</main>
</body>
</html>