Skip to content

Deploying SafeLine

Introduction

SafeLine is an open-source web application firewall (WAF) that uses semantic analysis and machine learning to protect web applications from attacks. Unlike traditional signature-based WAFs, SafeLine understands the context and meaning of HTTP requests, providing more accurate threat detection with fewer false positives.

Developed by Chaitin Tech, SafeLine offers enterprise-grade protection in an easy-to-deploy package. The semantic analysis engine can detect zero-day attacks and novel attack patterns that would bypass signature-based systems, while the intuitive dashboard makes security management accessible to teams without dedicated security expertise.

Key highlights of SafeLine:

  • Semantic Analysis: Context-aware attack detection beyond signatures
  • Machine Learning: Adaptive detection for emerging threats
  • Low False Positives: Intelligent analysis reduces alert fatigue
  • SQL Injection Protection: Deep detection of SQLi variants
  • XSS Prevention: Block cross-site scripting attacks
  • Bot Protection: Identify and block malicious bots
  • Rate Limiting: Prevent brute force and DDoS attacks
  • API Protection: Secure REST and GraphQL endpoints
  • Real-Time Dashboard: Visual security monitoring
  • Attack Analytics: Detailed threat intelligence
  • Easy Integration: Reverse proxy deployment model

This guide walks through deploying SafeLine on Klutch.sh using Docker, configuring protection for your applications, and monitoring security events.

Why Deploy SafeLine on Klutch.sh

Deploying SafeLine on Klutch.sh provides several advantages for web security:

Simplified Deployment: Klutch.sh automatically builds your SafeLine configuration without complex setup.

Persistent Storage: Attach volumes for configuration and security logs. Your rules and analytics survive restarts.

HTTPS by Default: Secure access to the management dashboard with automatic SSL certificates.

Scalable Resources: Allocate CPU and memory based on traffic volume and analysis depth.

GitHub Integration: Store configuration in version control for reproducible deployments.

Always-On Protection: 24/7 availability ensures continuous application security.

Prerequisites

Before deploying SafeLine on Klutch.sh, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your SafeLine configuration
  • Basic familiarity with Docker and reverse proxy concepts
  • Web applications to protect
  • (Optional) A custom domain for SafeLine dashboard

Deploying SafeLine on Klutch.sh

    Create Your Repository

    Create a new GitHub repository for your SafeLine deployment. Add a Dockerfile:

    FROM chaitin/safeline-mgt:latest
    ENV MGT_HTTP_PORT=9443
    ENV SAFELINE_DIR=/safeline
    EXPOSE 9443
    HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
    CMD curl -fsk https://localhost:9443/api/health || exit 1

    Push to GitHub

    Commit and push your Dockerfile to your GitHub repository.

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project.

    Create a New App

    Within your project, create a new app. Connect your GitHub account and select your repository.

    Configure HTTP Traffic

    In the deployment settings:

    • Select HTTP as the traffic type
    • Set the internal port to 9443

    Set Environment Variables

    Configure SafeLine settings:

    VariableValue
    MGT_HTTP_PORT9443
    SAFELINE_DIR/safeline

    Attach Persistent Volumes

    Add volumes for configuration and data:

    Mount PathRecommended SizePurpose
    /safeline20 GBConfiguration and databases
    /safeline/logs50 GBSecurity event logs

    Deploy Your Application

    Click Deploy to start the build process.

    Access Dashboard

    Once deployed, access the SafeLine dashboard at your deployment URL.

Initial Configuration

First Login

Set up your SafeLine instance:

  1. Access the management dashboard
  2. Create admin account
  3. Configure basic settings
  4. Add protected sites

Adding Protected Sites

Configure sites to protect:

  1. Navigate to Sites configuration
  2. Add new site
  3. Enter upstream server address
  4. Configure listening ports
  5. Enable protection rules

Protection Features

SQL Injection Prevention

SafeLine detects SQLi attacks:

  • Parameter analysis
  • Query structure detection
  • Encoding bypass prevention
  • ORM injection detection

XSS Protection

Block cross-site scripting:

  • Reflected XSS detection
  • Stored XSS prevention
  • DOM-based XSS identification
  • Context-aware filtering

Command Injection

Prevent command execution:

  • Shell command detection
  • Parameter injection blocking
  • Path traversal prevention

File Upload Security

Secure file uploads:

  • File type validation
  • Content inspection
  • Malicious file blocking

Bot Management

Bot Detection

Identify malicious bots:

  • Behavioral analysis
  • Fingerprinting techniques
  • Challenge-response tests

Rate Limiting

Configure rate limits:

  1. Access rate limiting settings
  2. Set requests per time window
  3. Configure action on limit
  4. Apply to specific paths

IP Blocking

Block malicious IPs:

  • Automatic blocking on attacks
  • Manual IP blacklisting
  • Geographic blocking
  • Whitelist trusted IPs

API Protection

REST API Security

Protect REST endpoints:

  • Method enforcement
  • Parameter validation
  • Response inspection

GraphQL Protection

Secure GraphQL APIs:

  • Query depth limiting
  • Complexity analysis
  • Introspection control

Dashboard and Monitoring

Security Dashboard

Monitor protection status:

  • Attack statistics
  • Traffic overview
  • Threat trends
  • Alert summary

Attack Analytics

Analyze security events:

  • Attack type distribution
  • Source analysis
  • Timeline visualization
  • Detailed event logs

Alerting

Configure notifications:

  1. Access alert settings
  2. Configure thresholds
  3. Set notification channels
  4. Test alert delivery

Rule Configuration

Detection Rules

Configure detection sensitivity:

ModeDescription
HighMaximum detection, more false positives
MediumBalanced detection
LowFewer false positives, may miss attacks

Custom Rules

Create custom detection rules:

  1. Access rule editor
  2. Define match conditions
  3. Set action (block, log, allow)
  4. Test and deploy

Whitelisting

Reduce false positives:

  • Whitelist specific paths
  • Exclude trusted parameters
  • Allow specific patterns

Performance Optimization

Caching

Optimize performance:

  • Enable response caching
  • Configure cache rules
  • Monitor cache effectiveness

Connection Handling

Configure connection settings:

  • Keep-alive timeout
  • Connection limits
  • Buffer sizes

Integration

Upstream Configuration

Configure protected applications:

Upstream Server: http://your-app:8080
Health Check: /health
Timeout: 30s

Load Balancing

Distribute traffic:

  • Round-robin
  • Least connections
  • IP hash

SSL/TLS

Configure encryption:

  • Import certificates
  • Configure protocols
  • Set cipher suites

Backup and Recovery

Configuration Backup

Export settings:

  1. Access backup settings
  2. Export configuration
  3. Store securely
  4. Test restoration

Log Retention

Configure log storage:

  • Set retention period
  • Archive old logs
  • Configure rotation

Troubleshooting

False Positives

Handle legitimate traffic blocks:

  • Review attack logs
  • Identify patterns
  • Add whitelist rules
  • Adjust sensitivity

Performance Issues

Address slowdowns:

  • Review resource usage
  • Check rule complexity
  • Optimize caching
  • Scale resources

Connectivity Problems

Resolve connection issues:

  • Verify upstream availability
  • Check network configuration
  • Review timeout settings
  • Test with curl

Best Practices

Security Hardening

  • Start with medium sensitivity
  • Fine-tune based on traffic
  • Regularly review logs
  • Keep SafeLine updated

Monitoring

  • Set up alerting
  • Review dashboards regularly
  • Analyze attack patterns
  • Document incidents

Maintenance

  • Regular configuration backups
  • Log archival
  • Rule updates
  • Performance monitoring

Additional Resources

Conclusion

Deploying SafeLine on Klutch.sh provides advanced web application security with semantic analysis and machine learning. With comprehensive attack detection, intuitive management, and detailed analytics, SafeLine protects your applications from sophisticated threats while minimizing false positives. Combined with Klutch.sh’s reliable hosting, you get always-on security that adapts to emerging threats.