Back to articles
AI & Cloud

Self-Host Stirling PDF with Nginx: Secure Internal Document Processing for Marketing Agencies

A detailed guide to deploying self-hosted Stirling PDF combined with Nginx for secure, efficient, and cost-effective internal document processing in marketing agencies. This...

DPTCloud Engineering4 min read
Self-Host Stirling PDF with Nginx: Secure Internal Document Processing for Marketing Agencies

Why Self-Hosted Solutions Are Essential for Internal Documents

In today’s marketing landscape, agencies rely heavily on internal documents such as reports, design drafts, campaign materials, and customer data. Using third-party online document processing services can expose sensitive information to security risks and result in high operational costs. A self-hosted Stirling PDF solution combined with Nginx offers a secure, efficient, and cost-effective way to process documents without depending on external platforms.

Stirling PDF + Nginx: Optimizing Performance and Security

Stirling PDF is an open-source document processing service that enables PDF conversion, merging, splitting, and manipulation directly on your server. When paired with Nginx—a powerful reverse proxy—this setup enhances performance, security, and scalability.

1. Deploying Self-Hosted Stirling PDF

To deploy Stirling PDF, you need a VPS or dedicated server with at least 4GB of RAM. Use the following command to install it via Docker:

docker run -d \
  --name stirling-pdf \
  -p 8080:8080 \
  -e STIRLING_PDF_API_KEY=your-secret-key \
  -v /path/to/data:/data \
  quay.io/username/stirling-pdf:latest

2. Configuring Nginx as a Reverse Proxy

To protect Stirling PDF from direct access and improve performance, configure Nginx as a reverse proxy. Create a configuration file at /etc/nginx/sites-available/stirling-pdf:

server {
    listen 80;
    server_name your-domain.com;

    location / {
        proxy_pass http://localhost:8080;
        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;
    }

    location /api/ {
        proxy_pass http://localhost:8080/api/;
        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;
    }

    # Protect API with authentication
    location /api/ {
        auth_basic "Restricted Access";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }
}

Preparation and Verification

Prerequisites Before Deployment

  • VPS or Dedicated Server (minimum 4GB RAM)
  • Domain or subdomain
  • SSL certificate (can use Let's Encrypt)
  • SSH access to the server

Verification Steps

  • Stirling PDF is running: docker ps
  • Nginx configuration is valid: nginx -t
  • Access https://your-domain.com to verify the interface
  • API is accessible: curl -H "Authorization: Bearer your-secret-key" https://your-domain.com/api/health

Cost-Efficient Solution for Marketing Agencies

Instead of paying hundreds of dollars monthly for services like PDF.co or Smallpdf, self-hosting Stirling PDF with Nginx enables agencies to:

  • Reduce long-term operational costs
  • Protect internal documents from data leaks
  • Optimize document processing performance
  • Retain full control over the system

Troubleshooting Common Issues

  • Cannot access Stirling PDF: Verify the Docker container is running and port 8080 is open.
  • Nginx returns 502 Bad Gateway: Check if Stirling PDF is running and responding correctly.
  • API not working: Confirm the STIRLING_PDF_API_KEY environment variable and authentication settings.

References

Related infrastructure & engineering guides: KubeVirt: A Comprehensive Solution for Running Legacy VMs on Kubernetes

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478