{"id":1314,"date":"2026-02-18T16:23:23","date_gmt":"2026-02-18T08:23:23","guid":{"rendered":"https:\/\/blog.guguan.us.kg\/?p=1314"},"modified":"2026-02-18T16:28:56","modified_gmt":"2026-02-18T08:28:56","slug":"%e5%9c%a8alpine-linux%e6%90%ad%e5%bb%bamtproto-proxy","status":"publish","type":"post","link":"https:\/\/blog.guguan.us.kg\/?p=1314","title":{"rendered":"\u5728 Alpine Linux \u642d\u5efa MTProto Proxy"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4f7f\u7528\u7684\u9879\u76ee\uff1a<a href=\"https:\/\/github.com\/seriyps\/mtproto_proxy\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">seriyps\/mtproto_proxy: High performance Erlang MTProto proxy that powers https:\/\/t.me\/socksy_bot<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9700\u8981\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\napk add coreutils erlang27-dev make git\n\n# \u4e0b\u8f7d\u4ee3\u7801\ncurl -L https:\/\/github.com\/seriyps\/mtproto_proxy\/archive\/master.tar.gz -o mtproto_proxy.tar.gz\n\n# \u89e3\u538b\u6e90\u4ee3\u7801\ntar -xvaf mtproto_proxy.tar.gz\n\nmv -T mtproto_proxy-master mtproto_proxy\n\ncd mtproto_proxy\/\n\n# \u8bbe\u7f6e\u76d1\u542c\u7aef\u53e3\nPORT=443\n# \u8bbe\u7f6e secret\nSECRET=`head -c 16 \/dev\/urandom | od -A n -t x1 -w128 | sed 's\/ \/\/g'`\n# \u8bbe\u7f6e\u4ece @MTProxybot \u83b7\u53d6\u7684 proxy tag\nTAG=\"47b8363ed5431e0868d2bead1a55dd50\"\n# \u8bbe\u7f6e TLS \u4f2a\u88c5\u57df\u540d\nTLS_DOMAIN=\"s3.amazonaws.com\"\n\n# \u5199\u5165\u914d\u7f6e\u6587\u4ef6\necho '\n%% -*- mode: erlang -*-\n&#91;\n {mtproto_proxy,\n  %% see src\/mtproto_proxy.app.src for examples.\n  &#91;\n   '${PROTO_ARG}'\n   {ports,\n    &#91;#{name => mtp_handler_1,\n       listen_ip => \"0.0.0.0\",\n       port => '${PORT}',\n       secret => &lt;&lt;\"'${SECRET}'\">>,\n       tag => &lt;&lt;\"'${TAG}'\">>}\n    ]}\n   ]},\n\n %% Logging config\n {kernel,\n  &#91;{logger_level, info},\n   {logger,\n    &#91;{handler, default, logger_std_h,\n      #{level => info,\n        config => #{type => file,\n                    file => \"\/var\/log\/mtproto-proxy\/application.log\",\n                    max_no_bytes => 104857600,  % 100MB\n                    max_no_files => 10,\n                    filesync_repeat_interval => no_repeat}}},\n     {handler, console, logger_std_h,\n      #{level => critical,\n        config => #{type => standard_io}}}\n    ]}]},\n {sasl, &#91;{errlog_type, error}]}\n].' >config\/prod-sys.config\n\n# \u7f16\u8bd1\nmake\n\n# \u590d\u5236\u5230\u5b89\u88c5\u8def\u5f84\ncp -r _build\/prod\/rel\/mtp_proxy \/opt\/\n\nmkdir -m 777 \/opt\/mtp_proxy\/log\/\n\n# \u67e5\u770b\u8fde\u63a5\u53c2\u6570 secret\necho -ne \"\\xee$(echo -n $SECRET | sed 's\/..\/\\\\x&amp;\/g')$TLS_DOMAIN\" | base64 -w 0 | tr '+\/' '-_'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">mtproto-proxy \u6ce8\u518c OpenRC \u670d\u52a1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/sbin\/openrc-run\n#\/etc\/init.d\/mtproto-proxy\n\ndescription=\"Starts the mtproto_proxy server\"\ndepend() {\n\tneed net\n\tuse dns\n\tafter local-fs remote-fs\n\tneed epmd\n}\ncommand=\"\/opt\/mtp_proxy\/bin\/mtp_proxy\"\ncommand_args=\"foreground\"\nsupervisor=\"supervise-daemon\"\nname=\"mtproto-proxy\"\nextra_commands=\"reload\"\nexport RUNNER_LOG_DIR=\"\/var\/log\/mtproto-proxy\"\nrc_ulimit=\"-n 40960\"\nrespawn_delay=5\nrespawn_max=10\n\nstop() {\n\tebegin \"Stopping mtproto_proxy\"\n\t$command stop\n\teend $?\n}\n\nreload() {\n\tebegin \"Reloading mtproto_proxy configuration\"\n\t$command rpcterms mtproto_proxy_app reload_config\n\teend $?\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">epmd \u6ce8\u518c OpenRC \u670d\u52a1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/sbin\/openrc-run\n#\/etc\/init.d\/epmd\n\ndescription=\"Erlang Port Mapper Daemon\"\ndepend() {\n\tneed net\n\tbefore mtproto-proxy\n}\n\ncommand=\"\/usr\/bin\/epmd\"\ncommand_args=\"-daemon\"\ncommand_user=\"daemon:daemon\"\n\nstop() {\n\tebegin \"Stopping epmd\"\n\t$command -kill\n\teend $?\n}\n\nstatus() {\n\t$command -names\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bbe\u7f6e\u53ef\u6267\u884c\u6743\u9650<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x \/etc\/init.d\/epmd \/etc\/init.d\/mtproto-proxy<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u542f\u52a8<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>service epmd start &amp;&amp; service mtproto-proxy start<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Alpine Linux \u642d\u5efa MTProxy \u7684\u7b80\u8981\u6d41\u7a0b<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1314","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts\/1314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1314"}],"version-history":[{"count":9,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts\/1314\/revisions"}],"predecessor-version":[{"id":1324,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts\/1314\/revisions\/1324"}],"wp:attachment":[{"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}