From 2d2e7eeb2620a87d987bbc574c8c2e03f2f59f5c Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 29 Sep 2022 13:59:18 -0500 Subject: [PATCH 1/3] To Caddy --- .../.nginx-autoindex-after.html | 1 - .../.nginx-autoindex-before.html | 62 ------------------- .../nginx-user-public/dotfiles-setup.d.fish | 19 ------ .../nginx-user-public/user-public-http.conf | 13 ---- .../nginx-user-public/user-public-server.conf | 13 ---- host/layer/public-webserver/Caddyfile | 8 +++ .../public-webserver/dotfiles-setup.d.fish | 17 +++++ 7 files changed, 25 insertions(+), 108 deletions(-) delete mode 100755 host/layer/nginx-user-public/.nginx-autoindex-after.html delete mode 100755 host/layer/nginx-user-public/.nginx-autoindex-before.html delete mode 100644 host/layer/nginx-user-public/dotfiles-setup.d.fish delete mode 100644 host/layer/nginx-user-public/user-public-http.conf delete mode 100644 host/layer/nginx-user-public/user-public-server.conf create mode 100644 host/layer/public-webserver/Caddyfile create mode 100644 host/layer/public-webserver/dotfiles-setup.d.fish diff --git a/host/layer/nginx-user-public/.nginx-autoindex-after.html b/host/layer/nginx-user-public/.nginx-autoindex-after.html deleted file mode 100755 index a446d53..0000000 --- a/host/layer/nginx-user-public/.nginx-autoindex-after.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/host/layer/nginx-user-public/.nginx-autoindex-before.html b/host/layer/nginx-user-public/.nginx-autoindex-before.html deleted file mode 100755 index 4d7cb3f..0000000 --- a/host/layer/nginx-user-public/.nginx-autoindex-before.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - diff --git a/host/layer/nginx-user-public/dotfiles-setup.d.fish b/host/layer/nginx-user-public/dotfiles-setup.d.fish deleted file mode 100644 index a48c103..0000000 --- a/host/layer/nginx-user-public/dotfiles-setup.d.fish +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env fish -set me (status -f) -set dfp $argv[1] -set h $argv[2] -set c $argv[3] - -pushd (dirname $me) -function _cp - sudo rm -f "$argv[2]" - echo "Copying $argv[1] to $argv[2]" - sudo cp "$argv[1]" "$argv[2]" -end - -_cp (pwd)/user-public-http.conf /etc/nginx/user-public-http.conf -_cp (pwd)/user-public-server.conf /etc/nginx/user-public-server.conf -_cp (pwd)/.nginx-autoindex-before.html /usr/share/nginx/html/.nginx-autoindex-before.html -_cp (pwd)/.nginx-autoindex-after.html /usr/share/nginx/html/.nginx-autoindex-after.html - -echo 'Don\'t forget to include the nginx files in your config inside their respective blocks!' diff --git a/host/layer/nginx-user-public/user-public-http.conf b/host/layer/nginx-user-public/user-public-http.conf deleted file mode 100644 index 5b63a87..0000000 --- a/host/layer/nginx-user-public/user-public-http.conf +++ /dev/null @@ -1,13 +0,0 @@ -disable_symlinks off; - -# for wasm games -types { - application/octet-stream clr; - application/octet-stream pdb; -} - -gzip on; -gzip_min_length 10240; -gzip_proxied expired no-cache no-store private auth; -gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml application/wasm; -gzip_disable msie6; diff --git a/host/layer/nginx-user-public/user-public-server.conf b/host/layer/nginx-user-public/user-public-server.conf deleted file mode 100644 index c430984..0000000 --- a/host/layer/nginx-user-public/user-public-server.conf +++ /dev/null @@ -1,13 +0,0 @@ -# need CORS? -# location ~* \.(eot|ttf|woff|woff2)$ { -# add_header Access-Control-Allow-Origin *; -# } - -location ~ ^/~(.+?)(/.*)?$ { - disable_symlinks off; - alias /home/$1/public$2; - index index.html index.htm; - autoindex on; - add_before_body "/.nginx-autoindex-before.html"; - add_after_body "/.nginx-autoindex-after.html"; -} diff --git a/host/layer/public-webserver/Caddyfile b/host/layer/public-webserver/Caddyfile new file mode 100644 index 0000000..b287e56 --- /dev/null +++ b/host/layer/public-webserver/Caddyfile @@ -0,0 +1,8 @@ +{ + admin "unix//run/caddy/admin.socket" +} + +{system.hostname} { + root * /usr/share/caddy + file_server browse +} diff --git a/host/layer/public-webserver/dotfiles-setup.d.fish b/host/layer/public-webserver/dotfiles-setup.d.fish new file mode 100644 index 0000000..0be7c2a --- /dev/null +++ b/host/layer/public-webserver/dotfiles-setup.d.fish @@ -0,0 +1,17 @@ +#!/usr/bin/env fish + +pushd (dirname (status -f)) +set dfp $argv[1] +set homedir $argv[2] +set xdgconfdir $argv[3] +set layerdir (pwd) + +function _ln + set source $argv[1] + set dest $argv[2] + sudo rm -f "$dest" + echo "Copying $source to $dest" + sudo ln -s "$source" "$dest" +end + +_ln $layerdir/Caddyfile /etc/caddy/Caddyfile From 934fac36651e62f21a6360c0ff768ccb8e833224 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 29 Sep 2022 15:21:05 -0500 Subject: [PATCH 2/3] webserver --- common/envs | 2 +- host/layer/public-webserver/Caddyfile | 8 - host/layer/public-webserver/caddy/Caddyfile | 11 + .../caddy/browse_template.html | 190 ++++++++++++++++++ .../public-webserver/dotfiles-setup.d.fish | 9 +- .../webserver-root/index.html | 6 + .../webserver-root/public-files/.gitignore | 3 + 7 files changed, 216 insertions(+), 13 deletions(-) delete mode 100644 host/layer/public-webserver/Caddyfile create mode 100755 host/layer/public-webserver/caddy/Caddyfile create mode 100644 host/layer/public-webserver/caddy/browse_template.html create mode 100644 host/layer/public-webserver/webserver-root/index.html create mode 100644 host/layer/public-webserver/webserver-root/public-files/.gitignore diff --git a/common/envs b/common/envs index d3d3272..2c2e3b3 100644 --- a/common/envs +++ b/common/envs @@ -23,4 +23,4 @@ host/laptop/postmates-macbook host/laptop/uber-macbook host/laptop/val-macbook host/layer/personal -host/layer/nginx-user-public +host/layer/public-webserver diff --git a/host/layer/public-webserver/Caddyfile b/host/layer/public-webserver/Caddyfile deleted file mode 100644 index b287e56..0000000 --- a/host/layer/public-webserver/Caddyfile +++ /dev/null @@ -1,8 +0,0 @@ -{ - admin "unix//run/caddy/admin.socket" -} - -{system.hostname} { - root * /usr/share/caddy - file_server browse -} diff --git a/host/layer/public-webserver/caddy/Caddyfile b/host/layer/public-webserver/caddy/Caddyfile new file mode 100755 index 0000000..b924229 --- /dev/null +++ b/host/layer/public-webserver/caddy/Caddyfile @@ -0,0 +1,11 @@ +{ + admin "unix//run/caddy/admin.socket" +} + +// http://127.0.0.1 http://0.0.0.0 http://{system.hostname} { + root * /srv/http + file_server { + browse /etc/caddy/browse_template.html + hide \.* + } +} diff --git a/host/layer/public-webserver/caddy/browse_template.html b/host/layer/public-webserver/caddy/browse_template.html new file mode 100644 index 0000000..c07ea60 --- /dev/null +++ b/host/layer/public-webserver/caddy/browse_template.html @@ -0,0 +1,190 @@ + + + + {{html .Name}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ {{range $i, $crumb := .Breadcrumbs}}{{html $crumb.Text}}{{if ne $i 0}}/{{end}}{{end}} +
+
+
+
+
+ + {{.NumDirs}} director{{if eq 1 .NumDirs}}y{{else}}ies{{end}} + {{.NumFiles}} file{{if ne 1 .NumFiles}}s{{end}} + {{- if ne 0 .Limit}} + (of which only {{.Limit}} are displayed) + {{- end}} +
+
+
+ + + + + + + + + + + + {{- range .Items}} + + + + {{- if .IsDir}} + + {{- else}} + + {{- end}} + + + + {{- end}} + +
+ {{- if and (eq .Sort "namedirfirst") (ne .Order "desc")}} + + {{- else if and (eq .Sort "namedirfirst") (ne .Order "asc")}} + + {{- else}} + + {{- end}} + + {{- if and (eq .Sort "name") (ne .Order "desc")}} + Name + {{- else if and (eq .Sort "name") (ne .Order "asc")}} + Name + {{- else}} + Name + {{- end}} + + {{- if and (eq .Sort "size") (ne .Order "desc")}} + Size + {{- else if and (eq .Sort "size") (ne .Order "asc")}} + Size + {{- else}} + Size + {{- end}} + + {{- if and (eq .Sort "time") (ne .Order "desc")}} + Modified + {{- else if and (eq .Sort "time") (ne .Order "asc")}} + Modified + {{- else}} + Modified + {{- end}} +
+ + {{- if .IsDir -}} + + {{- else -}} + + {{- end -}} + {{html .Name}} + + {{.HumanSize}}
+
+
+ + + diff --git a/host/layer/public-webserver/dotfiles-setup.d.fish b/host/layer/public-webserver/dotfiles-setup.d.fish index 0be7c2a..1b79105 100644 --- a/host/layer/public-webserver/dotfiles-setup.d.fish +++ b/host/layer/public-webserver/dotfiles-setup.d.fish @@ -6,12 +6,13 @@ set homedir $argv[2] set xdgconfdir $argv[3] set layerdir (pwd) -function _ln +function _p set source $argv[1] set dest $argv[2] - sudo rm -f "$dest" + sudo rm -rf "$dest" echo "Copying $source to $dest" - sudo ln -s "$source" "$dest" + sudo cp -r "$source" "$dest" end -_ln $layerdir/Caddyfile /etc/caddy/Caddyfile +_p $layerdir/caddy /etc/caddy +_p $layerdir/webserver-root /srv/http diff --git a/host/layer/public-webserver/webserver-root/index.html b/host/layer/public-webserver/webserver-root/index.html new file mode 100644 index 0000000..e7efd73 --- /dev/null +++ b/host/layer/public-webserver/webserver-root/index.html @@ -0,0 +1,6 @@ + + Public Web lyte.dev Machine + + + Public Files + \ No newline at end of file diff --git a/host/layer/public-webserver/webserver-root/public-files/.gitignore b/host/layer/public-webserver/webserver-root/public-files/.gitignore new file mode 100644 index 0000000..3aac695 --- /dev/null +++ b/host/layer/public-webserver/webserver-root/public-files/.gitignore @@ -0,0 +1,3 @@ +* +.* +!.gitignore From 8b5b43c5e9b6487883ad6f8a62882bff55601e3e Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 29 Sep 2022 19:35:10 -0500 Subject: [PATCH 3/3] Simplify --- .../caddy/browse_template.html | 147 ++++-------------- 1 file changed, 26 insertions(+), 121 deletions(-) diff --git a/host/layer/public-webserver/caddy/browse_template.html b/host/layer/public-webserver/caddy/browse_template.html index c07ea60..440269d 100644 --- a/host/layer/public-webserver/caddy/browse_template.html +++ b/host/layer/public-webserver/caddy/browse_template.html @@ -7,121 +7,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
{{range $i, $crumb := .Breadcrumbs}}{{html $crumb.Text}}{{if ne $i 0}}/{{end}}{{end}}
+
+ {{.NumDirs}} director{{if eq 1 .NumDirs}}y{{else}}ies{{end}} + {{.NumFiles}} file{{if ne 1 .NumFiles}}s{{end}} + {{- if ne 0 .Limit}} + (of which only {{.Limit}} are displayed) + {{- end}} +
-
-
- - {{.NumDirs}} director{{if eq 1 .NumDirs}}y{{else}}ies{{end}} - {{.NumFiles}} file{{if ne 1 .NumFiles}}s{{end}} - {{- if ne 0 .Limit}} - (of which only {{.Limit}} are displayed) - {{- end}} -
-
- - + {{- range .Items}} - @@ -131,7 +68,6 @@ {{- end}} - {{- end}} @@ -139,37 +75,6 @@
- {{- if and (eq .Sort "namedirfirst") (ne .Order "desc")}} - - {{- else if and (eq .Sort "namedirfirst") (ne .Order "asc")}} - - {{- else}} - - {{- end}} - - {{- if and (eq .Sort "name") (ne .Order "desc")}} - Name - {{- else if and (eq .Sort "name") (ne .Order "asc")}} - Name - {{- else}} - Name - {{- end}} + Name - {{- if and (eq .Sort "size") (ne .Order "desc")}} - Size - {{- else if and (eq .Sort "size") (ne .Order "asc")}} - Size - {{- else}} - Size - {{- end}} + Size - {{- if and (eq .Sort "time") (ne .Order "desc")}} - Modified - {{- else if and (eq .Sort "time") (ne .Order "asc")}} - Modified - {{- else}} - Modified - {{- end}} + Modified
- {{- if .IsDir -}} - - {{- else -}} - - {{- end -}} {{html .Name}} {{.HumanSize}}