
In questa guida vedremo come installare e configurare un Server AI completo e replicabile basato su Ubuntu 24.04 LTS e hardware Intel N100, ottimizzato per ambienti domestici o piccoli laboratori IT.
ARCHITETTURA E PREREQUISITI
L’infrastruttura prevede:
Ollama per l’esecuzione dei modelli LLM locali
Open-WebUI come interfaccia web moderna stile ChatGPT
Agent AI (RAG Server) per estendere le funzionalità con documenti, embedding e automazioni
Nginx con HTTPS per un accesso sicuro
Ottimizzazioni CPU, RAM (zram), LVM e hardening di base
La guida è completamente replicabile, strutturata passo-passo e pensata per ottenere un sistema:
Performante anche su hardware a basso consumo e Sicuro (zero porte AI esposte)
Pronto per utilizzo personale o laboratorio professionale
Al termine avrai un’infrastruttura AI locale stabile, organizzata e pronta per essere integrata nella tua rete (anche su VLAN dedicata).
Base: Ubuntu 24.04 LTS minimal
Hardware: Intel N100 – 16/32GB RAM – NVMe
INSTALLAZIONE DEL SISTEMA BASE
Aggiornamento sistema
|
0 1 2 |
sudo apt update sudo apt upgrade -y sudo apt autoremove -y |
OTTIMIZZAZIONE N100
Governor performance
|
0 1 2 |
sudo apt install cpufrequtils -y echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils sudo systemctl restart cpufrequtils |
ZRAM
|
0 1 |
sudo apt install zram-tools -y sudo nano /etc/default/zramswap |
Impostare la percentuale della memoria adeguata (es 50%)
|
0 |
sudo systemctl restart zramswap |
INSTALLAZIONE DOCKER
|
0 1 2 3 4 |
sudo apt install docker.io -y sudo systemctl enable docker sudo systemctl start docker sudo usermod -aG docker $USER newgrp docker |
INSTALLAZIONE OLLAMA
|
0 |
curl -fsSL https://ollama.com/install.sh | sh |
Procedere con l’Hardening Ollama:
|
0 |
sudo systemctl edit ollama |
Inserire il seguente output:
|
0 1 2 3 4 5 6 |
ini [Service] Environment="OLLAMA_NO_CLOUD=true" Environment="OLLAMA_HOST=127.0.0.1" Environment="OLLAMA_NUM_PARALLEL=1" Environment="OLLAMA_MAX_QUEUE=8" Environment="OLLAMA_KEEP_ALIVE=5m" |
Poi:
|
0 1 |
sudo systemctl daemon-reload sudo systemctl restart ollama |
Scaricare i modelli consigliati
|
0 1 2 3 |
ollama pull phi3 ollama pull mistral ollama pull deepseek-coder:6.7b-instruct-q4_K_M ollama pull nomic-embed-text |
INSTALLAZIONE OPEN-WEBUI
Creare una cartella persistente con i seguenti comandi:
|
0 1 |
sudo mkdir -p /data-ai/openwebui sudo chown -R $USER:$USER /data-ai |
Avviare il container sicuro con il comando:
|
0 |
docker run -d --name open-webui -p 127.0.0.1:3000:8080 -e OLLAMA_BASE_URL=http://127.0.0.1:11434 -e CORS_ALLOW_ORIGIN=https://ai.local -v /data-ai/openwebui:/app/backend/data --restart always ghcr.io/open-webui/open-webui:main |
INSTALLAZIONE DI NGINX PER HTTPS
|
0 1 |
sudo apt install nginx -y sudo mkdir -p /etc/nginx/ssl |
Generare un certificato self-signed con i seguenti comandi:
|
0 1 2 |
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:4096 \ -keyout /etc/nginx/ssl/ai.key \ -out /etc/nginx/ssl/ai.crt |
Procedere con la configurazione del vhost:
|
0 |
sudo nano /etc/nginx/sites-available/ai |
Contenuto completo da copiare all’interno del file di configurazione:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
nginx server { listen 80; server_name ai.local; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name ai.local; ssl_certificate /etc/nginx/ssl/ai.crt; ssl_certificate_key /etc/nginx/ssl/ai.key; ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; ssl_session_timeout 1d; ssl_session_cache shared:SSL:10m; ssl_session_tickets off; add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always; add_header X-Content-Type-Options nosniff; add_header X-Frame-Options DENY; add_header X-XSS-Protection "1; mode=block"; server_tokens off; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } |
Attivare il sito con i comandi:
|
0 1 2 |
sudo ln -s /etc/nginx/sites-available/ai /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx |
FIREWALL BASE
|
0 1 2 3 4 |
sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow 443/tcp sudo ufw allow from 192.168.3.0/24 to any port 22 sudo ufw enable |
VERIFICA FINALE
|
0 |
ss -tulnp |
Deve risultare:
|
0 1 2 3 4 |
0.0.0.0:443 0.0.0.0:80 0.0.0.0:22 127.0.0.1:3000 127.0.0.1:11434 |
BACKUP CONFIGURAZIONE
|
0 1 2 |
sudo mkdir -p /data-ai/backups sudo tar -czf /data-ai/backups/ai_stack_backup_$(date +%F).tar.gz /etc/nginx /etc/systemd/system/ollama.service.d /data-ai /home/$USER/.ollama |

0 commenti