Files
personal-servers/reverse_proxy/goaccess.sh
Roberto Alsina 7b5ce1a5e8 Add GoAccess metrics dashboard with WebSocket support
- Add GoAccess package to Docker container
- Create GoAccess startup script with real-time HTML generation
- Add metrics.ralsina.me server block with authentication
- Configure WebSocket proxy for live metrics updates
- Add password protection with .htpasswd
- Fix WebSocket URL to use proper HTTPS endpoint
- Update all server blocks to listen on 0.0.0.0:8080 for Fly.io compatibility

Co-Authored-By: z.ai LGM 4.5 <noreply@z.ai>
2025-10-03 10:53:26 -03:00

49 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# GoAccess real-time dashboard script
# Serves metrics dashboard on port 7890 with WebSocket support
echo "Starting GoAccess setup..."
# Wait for nginx to start and create logs
sleep 10
# Create log directory if it doesn't exist
mkdir -p /var/log/nginx
# Create HTML output directory
mkdir -p /usr/share/nginx/html/goaccess
# Create a dummy access log if it doesn't exist
touch /var/log/nginx/access.log
echo "Starting GoAccess..."
# Start GoAccess with real-time WebSocket support
# Remove unsupported options and use valid ones
goaccess /var/log/nginx/access.log \
--log-format=COMBINED \
--real-time-html \
--ws-url=wss://metrics.ralsina.me/ws \
--daemonize \
--output=/usr/share/nginx/html/goaccess/index.html &
# Get the PID
GOACCESS_PID=$!
echo "GoAccess started with PID: $GOACCESS_PID"
# Wait a moment and check if it's still running
sleep 3
if kill -0 $GOACCESS_PID 2>/dev/null; then
echo "GoAccess is running successfully"
else
echo "GoAccess failed to start, trying static HTML method..."
# Alternative: generate static HTML every 30 seconds
while true; do
goaccess /var/log/nginx/access.log \
--log-format=COMBINED \
--output=/usr/share/nginx/html/goaccess/index.html
echo "Generated static report at $(date)"
sleep 30
done &
fi