Files
2025-11-11 11:47:15 +01:00

71 lines
1.6 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
ensure_root
detect_pkg_manager
pkg_install curl
echo ""
echo "=== NGINX KI-Proxy Konfigurator ==="
echo ""
read -p "Pfad unter dem KI erreichbar sein soll (z.B. /ai): " KI_PATH
read -p "Backend-Adresse (z.B. http://127.0.0.1:11434): " KI_BACKEND
echo ""
echo "Ist Ollama installiert? (y/n)"
read OLLAMA
if [[ "$OLLAMA" =~ ^[Yy]$ ]]; then
echo "Ollama wird geprüft..."
if ! systemctl is-active --quiet ollama && ! pgrep ollama >/dev/null; then
echo "⚠️ Ollama läuft nicht. Bitte vorher installieren/starten."
else
echo "✅ Ollama läuft."
fi
fi
echo ""
echo "Soll zusätzlich der Memory-Server integriert werden? (y/n)"
read MEM
if [[ "$MEM" =~ ^[Yy]$ ]]; then
read -p "Memory Server URL (z.B. http://127.0.0.1:8085): " MEMORY_URL
fi
NGINX_CONF="/etc/nginx/conf.d/ai-proxy.conf"
$SUDO tee $NGINX_CONF >/dev/null <<EOF
location $KI_PATH/ {
proxy_pass $KI_BACKEND/;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$host;
}
EOF
if [[ "$MEM" =~ ^[Yy]$ ]]; then
$SUDO tee -a $NGINX_CONF >/dev/null <<EOF
location ${KI_PATH}_memory/ {
proxy_pass $MEMORY_URL/;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$host;
}
EOF
fi
echo ""
echo "Reloading nginx..."
$SUDO systemctl reload nginx
echo ""
echo "✅ Fertig!"
echo "KI UI erreichbar unter: http://<server-ip>$KI_PATH/"
if [[ "$MEM" =~ ^[Yy]$ ]]; then
echo "Memory erreichbar unter: http://<server-ip>${KI_PATH}_memory/"
fi