셀프 호스팅 동적 QR Codes: DIY 가이드

<\/script>\n
'; }, get iframeSnippet() { const domain = 'qrcodefyi.com'; const type = 'guide'; const slug = 'self-hosted-dynamic-qr'; return ''; }, get activeSnippet() { return this.method === 'script' ? this.scriptSnippet : this.iframeSnippet; }, copySnippet() { navigator.clipboard.writeText(this.activeSnippet).then(() => { this.copied = true; setTimeout(() => { this.copied = false; }, 2000); }); } }" @keydown.escape.window="open = false" @click.outside="open = false">

Embed This Widget

Theme


      
    

Widget powered by . Free, no account required.

Building your own dynamic QR system: URL shortener setup, redirect server, analytics database, and open-source tools.

Self-Hosted Dynamic QR Codes: DIY Guide

Building your own dynamic QR code system eliminates platform subscriptions, gives you full data control, and avoids vendor lock-in.

Architecture Components

1. URL shortener: Maps short codes to destination URLs - Database: PostgreSQL or Redis for fast key-value lookups - Short code generation: Random alphanumeric strings (6-8 characters) - Admin interface: Create, edit, delete URL mappings

2. Redirect server: Handles incoming scan requests - Receives requests to go.yourdomain.com/{code} - Looks up the destination URL in the database - Logs scan metadata (timestamp, IP, User-Agent) - Returns HTTP 301 or 302 redirect to the destination

3. Analytics engine: Processes and visualises scan data - Store raw scan events (time, IP, device, location) - IP geolocation lookup (MaxMind GeoLite2 or similar) - Dashboard for viewing scan trends, maps, and device breakdowns - API for programmatic analytics access

4. QR code generator: Creates QR code images - Python libraries: segno, qrcode - JavaScript libraries: qrcode.js - Integrate with the URL shortener to auto-generate codes on URL creation

Technology Stack Options

Component Options
Backend Django, Express.js, Go, Rails
Database PostgreSQL, MySQL, Redis
QR generation segno (Python), qrcode.js
Geolocation MaxMind GeoLite2
Hosting Any VPS, Kubernetes, serverless

Minimum Viable Implementation

A basic self-hosted system in Django:

  1. URL model: short_code, destination, created_at, is_active
  2. Scan model: url, timestamp, ip, user_agent, country
  3. Redirect view: lookup, log, redirect (3 database operations per scan)
  4. Admin: Django admin for URL management
  5. DNS: Point go.yourdomain.com to your server

Scaling Considerations

Scale Architecture
< 1K scans/day Single server, SQLite/PostgreSQL
1K-100K scans/day Server + Redis cache for lookups
100K+ scans/day Load balancer + multiple servers + async logging

Key Takeaways

  • Self-hosted dynamic QR requires URL shortener, redirect server, and analytics
  • Minimum viable implementation is achievable in a weekend with Django or Express
  • Redis caching handles redirect lookups at scale
  • Full data ownership eliminates privacy and vendor concerns
  • Operational overhead (hosting, monitoring, backups) is the trade-off