A lightweight HTTP proxy server for Epson POS printers that accepts XML-based print commands and converts them to printer-specific byte sequences. Supports USB and TCP connections with automatic retry logic and graceful error handling.
- Image Printing: Base64-encoded monochrome images with automatic centering
- Paper Cutting: Full and partial cut commands
- Cash Drawer: Kick drawer/cash drawer pulse commands
- USB: Direct USB device connection (e.g.,
/dev/usb/lp0) [UNSUPPORTED ON WINDOWS] - TCP: Network-connected printers (e.g.,
192.168.1.100:9100)
- EPOS XML format parsing
- Automatic retry with connection recovery (configurable retry delay)
- HTTPS support with auto-generated self-signed certificates
- Text printing
- Paper feeding
- Any thing outside of print + cut + drawer
go build -o epson-proxyDownload from the Releases page.
# Find your printer device
ls /dev/usb/lp*
# Run with USB connection
./epson-proxy -printer /dev/usb/lp0 -proto USB./epson-proxy -printer 192.168.1.100:9100 -proto TCP./epson-proxy -printer /dev/usb/lp0 -proto USB -secureUsage: epson-proxy [options]
Options:
-printer string
Printer connection string (required)
USB: /dev/usb/lp0
TCP: 192.168.1.100:9100
-proto string
Protocol: USB or TCP (required)
-receipt-width int
Receipt width in pixels (default 576)
-host string
Server host (default "127.0.0.1")
-port string
Server port (default "8000")
-secure
Use HTTPS (auto-generates self-signed certificate)
-allow-origins string
Comma-separated list of allowed CORS origins (empty = allow all)
Example: "https://example.com,https://app.example.com"
By default, the server allows all origins (*). For production use, you should whitelist specific origins:
./epson-proxy -printer /dev/usb/lp0 -proto USB -allow-origins "https://example.com,https://app.example.com"When CORS whitelist is configured, requests from non-whitelisted origins will receive a 403 Forbidden response with the message: CORS Error: Origin 'X' is not allowed
Send an XML request to the proxy:
curl -X POST http://localhost:8000 \
-H "Content-Type: application/xml" \
-d '<?xml version="1.0" encoding="utf-8"?>
<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">
<image width="384" height="100">
<base64-encoded-monochrome-image-data>
</image>
<cut/>
</epos-print>'curl -X POST http://localhost:8000 \
-H "Content-Type: application/xml" \
-d '<?xml version="1.0" encoding="utf-8"?>
<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">
<pulse/>
</epos-print>'The proxy accepts Epson's EPOS XML format:
<?xml version="1.0" encoding="utf-8"?>
<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">
<image width="384" height="100">
iVBORw0KGgoAAAANSUhEUgAA... (base64 encoded monochrome image)
</image>
<pulse/> <!-- Kick drawer -->
<cut/> <!-- Cut paper -->
</epos-print>- Always configure
-allow-originsin production environments - The default behavior (allow all) is suitable for development only
- Origins are matched case-insensitively
- Use
-secureflag for encrypted connections - Self-signed certificates are auto-generated for localhost
- For production, consider using proper SSL certificates
MIT License - See LICENSE