Sign inSign up

tonnamespace/reverse-proxy

By tonnamespace

•Updated over 1 year ago

Dockerized reverse proxy for TON blockchain Websites

Image
Networking
Web servers
0

885

tonnamespace/reverse-proxy repository overview

⁠TON Utils Reverse Proxy Docker

Docker Image Size (tag) Docker Pulls GitHub License GitHub Stars

šŸš€ A lightweight Docker image for running the TON Utils Reverse Proxy⁠ – effortlessly serve your websites through TON DNS domains. Perfect for decentralized hosting on the TON blockchain!


⁠🌟 Features

  • šŸ”‘ Automatic Private Key Generation: Secure setup in one command.
  • šŸ“± QR Code or Transaction URL: Easy domain linking via wallet scan.
  • āš™ļø Config Persistence: Mount volumes for seamless restarts.
  • 🌐 TON DNS Integration: Proxy traffic directly to your .ton domain.
  • šŸ›”ļø Secure & Simple: Environment-driven config with built-in tunneling.

ā šŸš€ Quick Start

⁠Step 1: First Initialization

Create a persistent config directory and initialize the proxy:

mkdir -p ./tonutils-config

docker run -it --rm \
  -v $(pwd)/tonutils-config:/app \
  -e FIRST_INIT=true \
  -e DOMAIN="namespace.ton" \
  tonnamespace/reverse-proxy:latest

This command will:

  • āœ… Generate a new private key and config.json.
  • šŸ“² Display a QR code for wallet-based ADNL address setup.
  • šŸ’¾ Save everything to your local ./tonutils-config directory.
⁠Step 2: Complete Domain Setup
  • Scan the QR code with your domain owner's TON wallet app.
  • Or, set TX_URL=true during init to get a direct transaction URL instead.

Wait for the transaction to confirm on the TON blockchain (usually ~5-10 seconds).

⁠Step 3: Run the Proxy

Launch the proxy in detached mode:

docker run -d \
  --name tonutils-proxy \
  -p 8765:8765 \
  -v $(pwd)/tonutils-config:/app \
  -e PROXY_PASS="https://namespace.my/" \
  -e EXTERNAL_IP="your_server_ip" \
  tonnamespace/reverse-proxy:latest

Your site is now live at http://namespace.ton! šŸŽ‰


ā āš™ļø Environment Variables

⁠Required for First Initialization
VariableRequiredDefaultDescription
FIRST_INITāœ…falseSet to true for first-time setup.
DOMAINāœ…-Your TON domain (e.g., namespace.ton).
⁠Required for Normal Operation
VariableRequiredDefaultDescription
PROXY_PASSāœ…-Backend URL to proxy requests to (e.g., https://namespace.my/).
EXTERNAL_IPāœ…-Public IP of your server (for ADNL resolution).
⁠Optional Variables
VariableRequiredDefaultDescription
LISTEN_IPāŒ0.0.0.0IP to bind the listener to.
PORTāŒ8765Port to expose the proxy on.
NETWORK_CONFIG_URLāŒhttps://ton.org/global.config.jsonTON network config endpoint.
TX_URLāŒfalseUse transaction URL instead of QR code.

ā šŸ’” Complete Setup Example

⁠1. Initialize with QR Code
mkdir -p ./tonutils-config

docker run -it --rm \
  -v $(pwd)/tonutils-config:/app \
  -e FIRST_INIT=true \
  -e DOMAIN="mydomain.ton" \
  tonnamespace/reverse-proxy:latest
⁠2. Initialize with Transaction URL
mkdir -p ./tonutils-config

docker run -it --rm \
  -v $(pwd)/tonutils-config:/app \
  -e FIRST_INIT=true \
  -e DOMAIN="mydomain.ton" \
  -e TX_URL=true \
  tonnamespace/reverse-proxy:latest
⁠3. Run the Proxy
docker run -d \
  --name my-ton-proxy \
  -p 8765:8765 \
  -v $(pwd)/tonutils-config:/app \
  -e PROXY_PASS="https://mywebsite.com/" \
  -e EXTERNAL_IP="1.2.3.4" \
  -e PORT="8765" \
  tonnamespace/reverse-proxy:latest

⁠🐳 Docker Compose Example

For easier management, use this docker-compose.yml:

version: '3.8'

services:
  # First: Run initialization
  tonutils-init:
    image: tonnamespace/reverse-proxy:latest
    container_name: tonutils-init
    volumes:
      - ./tonutils-config:/app
    environment:
      - FIRST_INIT=true
      - DOMAIN=namespace.ton
      - TX_URL=false  # Set to true for transaction URL
    profiles:
      - init
    stdin_open: true
    tty: true

  # Then: Run the proxy
  tonutils-proxy:
    image: tonnamespace/reverse-proxy:latest
    container_name: tonutils-proxy
    ports:
      - "8765:8765"
    volumes:
      - ./tonutils-config:/app
    environment:
      - PROXY_PASS=https://namespace.my/
      - EXTERNAL_IP=YOUR_HOST_EXTERNAL_IP
      - LISTEN_IP=0.0.0.0
      - PORT=8765
    restart: unless-stopped
    profiles:
      - proxy

Commands:

  • Initialization: docker-compose --profile init up tonutils-init
  • Proxy: docker-compose --profile proxy up -d tonutils-proxy

ā šŸ“ Configuration

The container handles config.json automatically:

  • Init Mode: Generates a fresh config with a private key.
  • Proxy Mode: Merges env vars into the existing config.

Example config.json:

{
  "proxy_pass": "https://namespace.my/",
  "private_key": "e7Y4DtgPtJP1UqlI5jGWhrLOotTWa3EjQwNSfh3akCw=",
  "external_ip": "YOUR_HOST_EXTERNAL_IP",
  "listen_ip": "0.0.0.0",
  "network_config_url": "https://ton.org/global.config.json",
  "custom_tunnel_network_config_url": "",
  "port": 8765,
  "tunnel_config": {
    "TunnelServerKey": "qT8TWTeZWdjMd/Qv7xRbfmYnO4xnJgZ4/UEWEU+tXgs=",
    "TunnelThreads": 1,
    "TunnelSectionsNum": 1,
    "NodesPoolConfigPath": "",
    "PaymentsEnabled": false,
    "Payments": {
      // ... payment configuration
    }
  },
  "version": 1
}

ā šŸ”„ Workflow

  1. Initialize šŸ”§: Run with FIRST_INIT=true to generate config and setup info.
  2. Link Domain šŸ”—: Scan QR or complete transaction to bind ADNL address.
  3. Launch Proxy šŸš€: Start with your backend URL and external IP.
  4. Go Live šŸŒ: Access your site via the TON domain – no central servers needed!

ā šŸ› ļø Troubleshooting

IssueSolution
"config.json not found"Run init with FIRST_INIT=true and check volume mount.
QR Code Not ShowingUse -it flags; try TX_URL=true for URL fallback.
Domain Not ResolvingConfirm transaction success; verify TON DNS setup and external IP.
Container Exits During InitSet DOMAIN correctly (e.g., mydomain.ton).
Proxy Not WorkingCheck env vars, backend accessibility, port exposure, and firewall rules.

Pro Tip: Always tail logs for real-time debugging!


ā šŸ“Š Logs

  • View init logs: docker logs tonutils-init
  • View proxy logs: docker logs tonutils-proxy
  • Follow live: docker logs -f tonutils-proxy

ā šŸ”’ Security Notes

  • šŸ” Private Key Handling: Auto-generated and stored in config.json – back it up!
  • šŸ›”ļø Best Practices: Use env vars for secrets; enable Docker secrets in prod.
  • šŸ“‚ Permissions: Restrict access to your config directory.
  • āš ļø Warning: Never commit config.json to public repos.

ā šŸ—ļø Building Locally

git clone https://github.com/TON-Namespace/docker-ton-reverse-proxy.git
cd docker-ton-reverse-proxy
docker build -t reverse-proxy .

Test with: docker run -it --rm -e FIRST_INIT=true -e DOMAIN="test.ton" reverse-proxy


ā šŸ¤ Contributing

We ā¤ļø contributions! Here's how:

  1. šŸ“ Fork the repo.
  2. 🌿 Create a feature branch (git checkout -b feature/amazing-feature).
  3. āœļø Make your changes and commit (git commit -m 'Add amazing feature').
  4. šŸš€ Push to the branch (git push origin feature/amazing-feature).
  5. šŸ“¤ Open a Pull Request!

Please ensure tests pass and add docs for new features.


ā šŸ“„ License

This project is licensed under the MIT License⁠ – free to use, modify, and distribute.



Built with ā¤ļø for the TON community. Questions? Open an issue!

Tag summary

Content type

Image

Digest

sha256:1d0435430…

Size

38.8 MB

Last updated

over 1 year ago

docker pull tonnamespace/reverse-proxy