mirror of
https://github.com/DarthJahus/mtproxy-docker.git
synced 2026-05-17 00:06:00 +03:00
initial commit
This commit is contained in:
15
.env.example
Normal file
15
.env.example
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Generate secret with: head -c 16 /dev/urandom | xxd -ps
|
||||||
|
SECRET=your_secret_here
|
||||||
|
|
||||||
|
# Tag from @MTProxybot (optional)
|
||||||
|
#PROXY_TAG=your_tag_here
|
||||||
|
|
||||||
|
# Number of workers (default: 2)
|
||||||
|
WORKERS=2
|
||||||
|
|
||||||
|
# Client port (default: 443)
|
||||||
|
PORT=443
|
||||||
|
|
||||||
|
# Stats port (default: 8888)
|
||||||
|
STATS_PORT=8888
|
||||||
|
|
||||||
42
Dockerfile
Normal file
42
Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
FROM ubuntu:24.04
|
||||||
|
|
||||||
|
LABEL maintainer="jahus"
|
||||||
|
LABEL description="Up-to-date MTProxy for Telegram"
|
||||||
|
LABEL version="1.0.0"
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
build-essential \
|
||||||
|
libssl-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
xxd \
|
||||||
|
cron && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /opt
|
||||||
|
RUN git clone https://github.com/TelegramMessenger/MTProxy && \
|
||||||
|
cd MTProxy && \
|
||||||
|
make && \
|
||||||
|
cp objs/bin/mtproto-proxy /usr/local/bin/ && \
|
||||||
|
cd .. && \
|
||||||
|
rm -rf MTProxy
|
||||||
|
|
||||||
|
WORKDIR /data
|
||||||
|
|
||||||
|
COPY update-config.sh /usr/local/bin/
|
||||||
|
COPY entrypoint.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/update-config.sh /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
EXPOSE 443 8888
|
||||||
|
|
||||||
|
COPY healthcheck.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/healthcheck.sh
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||||
|
CMD /usr/local/bin/healthcheck.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
|
|
||||||
42
entrypoint.sh
Normal file
42
entrypoint.sh
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -f /data/proxy-secret ] || [ ! -f /data/proxy-multi.conf ]; then
|
||||||
|
echo "Downloading initial configuration..."
|
||||||
|
/usr/local/bin/update-config.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "0 3 * * * /usr/local/bin/update-config.sh" | crontab -
|
||||||
|
|
||||||
|
cron
|
||||||
|
|
||||||
|
if [ -z "$SECRET" ]; then
|
||||||
|
echo "ERROR: SECRET environment variable is not set!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
WORKERS=${WORKERS:-1}
|
||||||
|
PORT=${PORT:-443}
|
||||||
|
STATS_PORT=${STATS_PORT:-8888}
|
||||||
|
USER=${USER:-nobody}
|
||||||
|
|
||||||
|
TAG_OPTION=""
|
||||||
|
if [ -n "$PROXY_TAG" ]; then
|
||||||
|
TAG_OPTION="-P $PROXY_TAG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting MTProxy..."
|
||||||
|
echo "Port: $PORT"
|
||||||
|
echo "Stats port: $STATS_PORT"
|
||||||
|
echo "Workers: $WORKERS"
|
||||||
|
echo "Secret: ${SECRET:0:8}..."
|
||||||
|
|
||||||
|
exec mtproto-proxy \
|
||||||
|
-u $USER \
|
||||||
|
-p $STATS_PORT \
|
||||||
|
-H $PORT \
|
||||||
|
-S $SECRET \
|
||||||
|
$TAG_OPTION \
|
||||||
|
--aes-pwd /data/proxy-secret \
|
||||||
|
/data/proxy-multi.conf \
|
||||||
|
-M $WORKERS \
|
||||||
|
--address 0.0.0.0
|
||||||
3
healthcheck.sh
Normal file
3
healthcheck.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
curl -f http://localhost:${STATS_PORT:-8888}/stats || exit 1
|
||||||
|
|
||||||
8
update-config.sh
Normal file
8
update-config.sh
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd /data
|
||||||
|
curl -s https://core.telegram.org/getProxySecret -o proxy-secret
|
||||||
|
curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf
|
||||||
|
echo "$(date): Configuration updated" >> /data/update.log
|
||||||
|
|
||||||
|
pkill -HUP mtproto-proxy
|
||||||
|
|
||||||
Reference in New Issue
Block a user