Last active
February 28, 2024 11:00
-
-
Save jniltinho/ff71aeca0fefb3c93e457bea823d228f to your computer and use it in GitHub Desktop.
Install filebrowser + Caddy
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
#!/bin/bash | |
## Links | |
## Ubuntu|Debian|Linux | |
## https://github.com/filebrowser/filebrowser | |
## https://github.com/caddyserver/caddy | |
## https://github.com/tenox7/wfm | |
## https://www.youtube.com/watch?v=W2yZ5_sd9Hc | |
## https://technotim.live/posts/meet-file-browser/ | |
VERSION=v2.27.0 | |
apt update | |
apt install -y curl | |
mkdir -p /opt/filebrowser/data | |
cd /opt/filebrowser | |
curl -LO --progress-bar https://github.com/filebrowser/filebrowser/releases/download/$VERSION/linux-amd64-filebrowser.tar.gz | |
tar -xzf linux-amd64-filebrowser.tar.gz | |
rm -f linux-amd64-filebrowser.tar.gz CHANGELOG.md LICENSE README.md | |
cat <<'EOF' >/etc/systemd/system/filebrowser.service | |
[Unit] | |
Description=Start Filebrowser Service | |
ConditionPathExists=/opt/filebrowser | |
After=network.target | |
[Service] | |
Type=simple | |
#User=root | |
#Group=root | |
WorkingDirectory=/opt/filebrowser | |
ExecStart=/opt/filebrowser/filebrowser --address=127.0.0.1 --port=8080 --root=/opt/filebrowser/data | |
Restart=on-failure | |
RestartSec=10 | |
StandardOutput=append:/opt/filebrowser/filebrowser.log | |
StandardError=append:/opt/filebrowser/filebrowser.log | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
## Add Caddy | |
mkdir /etc/caddy | |
groupadd --system caddy | |
useradd --system --gid caddy --create-home --home-dir /var/lib/caddy --shell /usr/sbin/nologin --comment "Caddy web server" caddy | |
cd /tmp | |
curl -LO https://github.com/caddyserver/caddy/releases/download/v2.7.6/caddy_2.7.6_linux_amd64.tar.gz | |
tar -xvf caddy_2.7.6_linux_amd64.tar.gz | |
mv caddy /usr/bin/caddy | |
cat <<'EOF' >/etc/systemd/system/caddy.service | |
[Unit] | |
Description=Caddy | |
Documentation=https://caddyserver.com/docs/ | |
After=network.target network-online.target | |
Requires=network-online.target | |
[Service] | |
Type=notify | |
User=caddy | |
Group=caddy | |
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile | |
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force | |
TimeoutStopSec=5s | |
LimitNOFILE=1048576 | |
PrivateTmp=true | |
ProtectSystem=full | |
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE | |
StandardOutput=append:/var/lib/caddy/caddy.log | |
StandardError=append:/var/lib/caddy/caddy.log | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat <<'EOF' >/etc/caddy/Caddyfile | |
https://filebrowser.domain.com | |
reverse_proxy 127.0.0.1:8080 | |
EOF | |
systemctl daemon-reload | |
systemctl enable caddy.service filebrowser.service | |
systemctl start filebrowser.service | |
systemctl start caddy.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment