Bound VPS log retention and quiet routine Hub traffic
This commit is contained in:
1 parent
5ccead65f6
commit
799ad8aad6
8 files changed
+1063
-43
No files matched your search
+15
-36
@@ -153,41 +153,20 @@ PY
|
||||
}
|
||||
|
||||
install_log_limits() {
|
||||
$SUDO mkdir -p /etc/systemd/journald.conf.d /etc/nginx/conf.d
|
||||
$SUDO tee /etc/systemd/journald.conf.d/owrt-remote-limits.conf >/dev/null <<'EOF'
|
||||
[Journal]
|
||||
SystemMaxUse=256M
|
||||
SystemKeepFree=512M
|
||||
MaxRetentionSec=7day
|
||||
RateLimitIntervalSec=30s
|
||||
RateLimitBurst=2000
|
||||
Compress=yes
|
||||
EOF
|
||||
$SUDO tee /etc/nginx/conf.d/owrt-remote-log-policy.conf >/dev/null <<'EOF'
|
||||
# Successful long-poll and terminal reads are expected traffic.
|
||||
# Keep 4xx/5xx responses in access.log for diagnostics.
|
||||
map "$request_uri:$status" $owrt_remote_access_log {
|
||||
default 1;
|
||||
~^/api/notifications/wait[^:]*:2[0-9][0-9]$ 0;
|
||||
~^/api/ssh-session/[^/]+/read[^:]*:2[0-9][0-9]$ 0;
|
||||
}
|
||||
access_log /var/log/nginx/access.log combined if=$owrt_remote_access_log;
|
||||
EOF
|
||||
$SUDO tee /etc/logrotate.d/owrt-remote >/dev/null <<'EOF'
|
||||
/var/log/nginx/*.log {
|
||||
daily
|
||||
rotate 7
|
||||
size 50M
|
||||
missingok
|
||||
notifempty
|
||||
compress
|
||||
delaycompress
|
||||
copytruncate
|
||||
}
|
||||
EOF
|
||||
$SUDO systemctl daemon-reload >/dev/null 2>&1 || true
|
||||
$SUDO systemctl reload-or-restart systemd-journald >/dev/null 2>&1 || true
|
||||
$SUDO journalctl --vacuum-size=256M --vacuum-time=7d >/dev/null 2>&1 || true
|
||||
info "Настраиваю ежедневную ротацию журналов и защиту диска..."
|
||||
if ! command -v logrotate >/dev/null 2>&1; then
|
||||
apt_get install -y logrotate || die "не удалось установить logrotate"
|
||||
fi
|
||||
maintenance_candidate="$(mktemp /tmp/owrt-log-maintenance.XXXXXX.py)" || die "не удалось создать временный файл"
|
||||
if ! curl -fsSL --max-time 120 -o "$maintenance_candidate" "$RAW_BASE/vps/log-maintenance.py?v=$(date +%s)"; then
|
||||
rm -f "$maintenance_candidate"
|
||||
die "не удалось загрузить обслуживание журналов"
|
||||
fi
|
||||
if ! $SUDO python3 "$maintenance_candidate" install; then
|
||||
rm -f "$maintenance_candidate"
|
||||
die "не удалось настроить обслуживание журналов; смотри причину выше"
|
||||
fi
|
||||
rm -f "$maintenance_candidate"
|
||||
}
|
||||
|
||||
install_xray_service() {
|
||||
@@ -329,12 +308,12 @@ main() {
|
||||
install_xray_binary
|
||||
install_files
|
||||
install_python_deps_v2
|
||||
install_log_limits
|
||||
install_xray_service
|
||||
open_firewall
|
||||
start_hub
|
||||
check_hub || die "Hub установлен, но сервис не поднялся. Лог выше."
|
||||
enable_https "$host"
|
||||
install_log_limits
|
||||
print_result "$host"
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user