This document outlines security best practices for your VPN infrastructure.
Always use cryptographically secure random generation:
# UUIDs
cat /proc/sys/kernel/random/uuid
# or: uuidgen
# Passwords
openssl rand -base64 32# Set appropriate permissions
chmod 600 .env
chmod 700 config/
# Never commit sensitive files to version control
# (already handled by .gitignore)- Change UUIDs and passwords every 3-6 months
- Update client configurations after rotation
- Keep a secure record of old credentials during transition
Only open necessary ports:
# Russian Server
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 443/tcp
sudo ufw allow 8443/tcp
sudo ufw allow 9443/tcp
sudo ufw allow 9443/udp
sudo ufw allow 10443/tcp
sudo ufw enable
# EU Server
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 443/tcp
sudo ufw enable# Disable password authentication
sudo nano /etc/ssh/sshd_config
# Set: PasswordAuthentication no
# Set: PubkeyAuthentication yes
# Restart SSH
sudo systemctl restart sshdInstall and configure fail2ban to prevent brute-force attacks:
sudo apt install fail2ban
sudo systemctl enable fail2ban
sudo systemctl start fail2ban# System updates
sudo apt update && sudo apt upgrade -y
# Docker image updates
cd /opt/dt_vpn/russian-server
docker-compose pull
docker-compose up -d
cd /opt/dt_vpn/eu-server
docker-compose pull
docker-compose up -dFor production use, add TLS encryption:
Using Let's Encrypt (free):
sudo apt install certbot
sudo certbot certonly --standalone -d your-domain.comUpdate your configuration to use certificates. Example for VLESS:
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {
"certificates": [
{
"certificateFile": "/etc/letsencrypt/live/your-domain.com/fullchain.pem",
"keyFile": "/etc/letsencrypt/live/your-domain.com/privkey.pem"
}
]
}
}Consider implementing rate limiting to prevent abuse:
# Using iptables
sudo iptables -A INPUT -p tcp --dport 443 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j DROP# Install monitoring tools
sudo apt install iftop nethogs
# Monitor real-time traffic
sudo iftop -i eth0Regularly check logs for suspicious activity:
# Russian server logs
docker-compose -f /opt/dt_vpn/russian-server/docker-compose.yml logs --since 24h | grep -i error
# EU server logs
docker-compose -f /opt/dt_vpn/eu-server/docker-compose.yml logs --since 24h | grep -i error- Only provide credentials to trusted users
- Keep a record of who has access
- Revoke credentials when no longer needed
You can add geo-blocking rules in Xray configuration:
"routing": {
"rules": [
{
"type": "field",
"ip": [
"geoip:cn",
"geoip:ru"
],
"outboundTag": "block"
}
]
}# Create backup script
#!/bin/bash
DATE=$(date +%Y%m%d)
tar -czf vpn-backup-$DATE.tar.gz \
/opt/dt_vpn/russian-server/.env \
/opt/dt_vpn/eu-server/.env \
/opt/dt_vpn/russian-server/config/ \
/opt/dt_vpn/eu-server/config/
# Store backup securely (encrypted)
gpg -c vpn-backup-$DATE.tar.gz
rm vpn-backup-$DATE.tar.gzDocument your recovery procedure:
- Server IP addresses
- Credential location
- Configuration backup location
- Client notification procedure
Use the provided monitor script:
# Run manually
cd /opt/dt_vpn/russian-server
./scripts/monitor.sh
# Or setup cron job for alerts
crontab -e
# Add: */15 * * * * /opt/dt_vpn/russian-server/scripts/monitor.sh | grep -i error && mail -s "VPN Alert" admin@example.comPrevent logs from filling disk:
# Docker logs are rotated automatically
# Check docker daemon.json for settings
cat /etc/docker/daemon.json- Immediately change all UUIDs and passwords
- Update Russian server configuration
- Restart services
- Notify legitimate users with new credentials
- Review logs for unauthorized access
- Consider rotating the EU server
- Disconnect from network
- Analyze logs and system state
- Rebuild from clean backup
- Change all credentials
- Review security measures
- Notify users of potential exposure
- Minimize logging of user data
- Comply with local data protection laws
- Have a clear privacy policy for users
Create clear terms of service:
- Prohibited activities
- Bandwidth limits
- Legal responsibilities
- Account termination conditions
- Strong UUIDs and passwords generated
- Firewall configured on both servers
- SSH hardened (key-only authentication)
- Regular update schedule established
- Monitoring script configured
- Backup strategy implemented
- Incident response plan documented
- TLS certificates configured (production)
- Fail2ban installed
- Log rotation configured
- Access control list maintained
- Terms of service created
If you discover a security vulnerability:
- Do not disclose publicly
- Document the issue
- Contact the administrator
- Provide steps to reproduce