Skip to content

Support Local Bot API through proxy #28

@ZenonEl

Description

@ZenonEl

Description

Self-hosted Telegram Bot API (telegram-bot-api Docker image) needs to connect to Telegram servers. In regions where Telegram is blocked, it needs proxy support.

Options

  1. proxychains in Docker — wrap telegram-bot-api binary with proxychains4 configured to use host SOCKS5 proxy
  2. tun2socks — create a tun device that routes all traffic through SOCKS5
  3. Docker network with Tor — add Tor container, route Bot API traffic through it
  4. iptables + redsocks — transparent proxy at network level

Simplest approach

Option 1: Add proxychains to Dockerfile, configure via environment variable.

FROM aiogram/telegram-bot-api:latest
RUN apk add --no-cache proxychains-ng
COPY proxychains.conf /etc/proxychains.conf
ENTRYPOINT ["proxychains4", "telegram-bot-api"]

Config needed

  • PROXY_HOST and PROXY_PORT environment variables
  • proxychains.conf template with substitution

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions