mirror of
https://github.com/tteck/Proxmox.git
synced 2024-11-24 05:25:30 +00:00
Added Traefik (#3021)
This commit is contained in:
parent
2a8a65e754
commit
07585658b0
77
ct/traefik.sh
Normal file
77
ct/traefik.sh
Normal file
@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env bash
|
||||
source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func)
|
||||
# Copyright (c) 2021-2024 tteck
|
||||
# Author: tteck (tteckster)
|
||||
# License: MIT
|
||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||
|
||||
function header_info {
|
||||
clear
|
||||
cat <<"EOF"
|
||||
______ _____ __
|
||||
/_ __/________ ____ / __(_) /__
|
||||
/ / / ___/ __ `/ _ \/ /_/ / //_/
|
||||
/ / / / / /_/ / __/ __/ / ,<
|
||||
/_/ /_/ \__,_/\___/_/ /_/_/|_|
|
||||
|
||||
EOF
|
||||
}
|
||||
header_info
|
||||
echo -e "Loading..."
|
||||
APP="Traefik"
|
||||
var_disk="2"
|
||||
var_cpu="1"
|
||||
var_ram="512"
|
||||
var_os="debian"
|
||||
var_version="12"
|
||||
variables
|
||||
color
|
||||
catch_errors
|
||||
|
||||
function default_settings() {
|
||||
CT_TYPE="1"
|
||||
PW=""
|
||||
CT_ID=$NEXTID
|
||||
HN=$NSAPP
|
||||
DISK_SIZE="$var_disk"
|
||||
CORE_COUNT="$var_cpu"
|
||||
RAM_SIZE="$var_ram"
|
||||
BRG="vmbr0"
|
||||
NET="dhcp"
|
||||
GATE=""
|
||||
APT_CACHER=""
|
||||
APT_CACHER_IP=""
|
||||
DISABLEIP6="no"
|
||||
MTU=""
|
||||
SD=""
|
||||
NS=""
|
||||
MAC=""
|
||||
VLAN=""
|
||||
SSH="no"
|
||||
VERB="no"
|
||||
echo_default
|
||||
}
|
||||
|
||||
function update_script() {
|
||||
header_info
|
||||
if [[ ! -f /etc/systemd/system/traefik.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
|
||||
msg_info "Updating $APP LXC"
|
||||
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
|
||||
wget -q https://github.com/traefik/traefik/releases/download/v${RELEASE}/traefik_v${RELEASE}_linux_amd64.tar.gz
|
||||
tar -C /tmp -xzf traefik*.tar.gz
|
||||
mv /tmp/traefik*/traefik /usr/bin/
|
||||
rm -rf traefik*.tar.gz
|
||||
msg_ok "Updated $APP LXC"
|
||||
else
|
||||
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
start
|
||||
build_container
|
||||
description
|
||||
|
||||
msg_ok "Completed Successfully!\n"
|
||||
echo -e "${APP} should be reachable by going to the following URL.
|
||||
${BL}http://${IP}:8080${CL} \n"
|
117
install/traefik-install.sh
Normal file
117
install/traefik-install.sh
Normal file
@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2021-2024 tteck
|
||||
# Author: tteck (tteckster)
|
||||
# License: MIT
|
||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||
|
||||
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
|
||||
color
|
||||
verb_ip6
|
||||
catch_errors
|
||||
setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Installing Dependencies"
|
||||
$STD apt-get install -y curl
|
||||
$STD apt-get install -y sudo
|
||||
$STD apt-get install -y mc
|
||||
$STD apt-get install -y gpg
|
||||
$STD apt-get install -y apt-transport-https
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
RELEASE=$(curl -s https://api.github.com/repos/traefik/traefik/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||
msg_info "Installing Traefik v${RELEASE}"
|
||||
mkdir -p /etc/traefik/{conf.d,ssl}
|
||||
wget -q https://github.com/traefik/traefik/releases/download/v${RELEASE}/traefik_v${RELEASE}_linux_amd64.tar.gz
|
||||
tar -C /tmp -xzf traefik*.tar.gz
|
||||
mv /tmp/traefik /usr/bin/
|
||||
rm -rf traefik*.tar.gz
|
||||
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
||||
msg_ok "Installed Traefik v${RELEASE}"
|
||||
|
||||
msg_info "Creating Traefik configuration"
|
||||
cat <<EOF >/etc/traefik/traefik.yaml
|
||||
providers:
|
||||
file:
|
||||
directory: /etc/traefik/conf.d/
|
||||
|
||||
entryPoints:
|
||||
web:
|
||||
address: ':80'
|
||||
http:
|
||||
redirections:
|
||||
entryPoint:
|
||||
to: websecure
|
||||
scheme: https
|
||||
websecure:
|
||||
address: ':443'
|
||||
http:
|
||||
middlewares:
|
||||
- crowdsec-bouncer@file
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
traefik:
|
||||
address: ':8080'
|
||||
|
||||
certificatesResolvers:
|
||||
letsencrypt:
|
||||
acme:
|
||||
email: "foo@bar.com"
|
||||
storage: /etc/traefik/ssl/acme.json
|
||||
tlsChallenge: {}
|
||||
|
||||
api:
|
||||
dashboard: true
|
||||
insecure: true
|
||||
|
||||
log:
|
||||
filePath: /var/log/traefik/traefik.log
|
||||
format: json
|
||||
level: INFO
|
||||
|
||||
accessLog:
|
||||
filePath: /var/log/traefik/traefik-access.log
|
||||
format: json
|
||||
filters:
|
||||
statusCodes:
|
||||
- "200"
|
||||
- "400-599"
|
||||
retryAttempts: true
|
||||
minDuration: "10ms"
|
||||
bufferingSize: 0
|
||||
fields:
|
||||
headers:
|
||||
defaultMode: drop
|
||||
names:
|
||||
User-Agent: keep
|
||||
EOF
|
||||
msg_ok "Created Traefik configuration"
|
||||
|
||||
msg_info "Creating Service"
|
||||
cat <<EOF >/etc/systemd/system/traefik.service
|
||||
[Unit]
|
||||
Description=Traefik is an open-source Edge Router that makes publishing your services a fun and easy experience
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
ExecStart=/usr/bin/traefik --configFile=/etc/traefik/traefik.yaml
|
||||
Restart=on-failure
|
||||
ExecReload=/bin/kill -USR1 \$MAINPID
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl enable -q --now traefik.service
|
||||
msg_ok "Created Service"
|
||||
|
||||
|
||||
motd_ssh
|
||||
customize
|
||||
|
||||
msg_info "Cleaning up"
|
||||
$STD apt-get -y autoremove
|
||||
$STD apt-get -y autoclean
|
||||
msg_ok "Cleaned"
|
Loading…
Reference in New Issue
Block a user