SSR后端篇-通过Docker部署端口偏移详解-CentOS7环境

最近研究端口偏移,需要用到Docker,然后发现通过docker部署后端非常方便(当然不止单端口)。

前提我们需要一台CentOS 7 环境的机器(废话)

第一步,我们安装Docker

wget -qO- get.docker.com | bash

启动Docker

systemctl start docker

检查docker状态

systemctl status docker

设置开机自启

systemctl enable docker

第二步,添加镜像和容器

docker run -d --name=容器名称 -e NODE_ID=节点ID -e API_INTERFACE=modwebapi -e WEBAPI_URL=节点地址 -e SPEEDTEST=0 -e WEBAPI_TOKEN=对接密钥 --log-opt max-size=50m --log-opt max-file=3 -p 偏移后端口:承载端口/tcp -p 偏移后端口:承载端口/udp --restart=always stone0906/ssrmuv2

将以上汉字替换为自己的信息,偏移后端口就是面板设置好偏移后的端口,承载端口同理(都是废话)

第三步,关闭防火墙(如果节点已经正常运行,请忽略此步)

停止firewall

systemctl stop firewalld.service

禁止firewall开机启动

systemctl disable firewalld.service

当然,你用白名单更好(当我没说)

最后,废话总结篇
至此,后端部署已经完成,我有时间再写前端和补充后端其他镜像。

已有 11 条评论
  1. Martin

    你好 这个后端是只支持ssr吗 还是v2ray也支持的呢

    Martin 2020年6月9日, 18:05回复
    1. 小忆

      这是ssr后端

      小忆 2020年6月10日, 23:09回复
  2. okak

    大佬有没有非docker的后端教程,nat鸡不支持docker /哭/

    okak 2020年3月1日, 17:29回复
    1. 小忆

      一般情况下,nat都支持docker

      小忆 2020年3月1日, 17:35回复
      1. okak

        你好,我重新找了个支持docker的nat鸡,开始按照您的教程操作发现不行,后来仔细检查发现您的教程第二步中 “ WEBAPI_TOKEN==对接密钥 " 多了个 = ,导致前后端token不一致,无法连接。(虽然另一个不支持docker的nat鸡,手动操作了很多遍,还是没法对接 /大哭/ )

        okak 2020年3月3日, 16:13回复
        1. 小忆

          非常感谢指出错误,我会检查文章并修正!

          不支持docker的,可以正常安装脚本,然后使用端口映射也可以达到效果

          小忆 2020年3月7日, 21:35回复
      2. okak

        大佬,自己手动对接,操作了很多次,但一直无法成功对接前端。 /心态崩裂/
        能帮忙看一下是什么原因吗?
        以下是调试的错误信息:

        loaded collections.OrderedDict
        IPv6 not support
        ERROR: Traceback (most recent call last):
        File "/root/shadowsocks/webapi_utils.py", line 23, in getApi
        timeout=10)
        File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 501, in get
        return self.request('GET', url, **kwargs)
        File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 488, in request
        resp = self.send(prep, **send_kwargs)
        File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 609, in send
        r = adapter.send(request, **kwargs)
        File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 423, in send
        timeout=timeout
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
        chunked=chunked)
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
        self._validate_conn(conn)
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
        conn.connect()
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connection.py", line 333, in connect
        cert = self.sock.getpeercert()
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 343, in getpeercert
        'subjectAltName': get_subj_alt_name(x509)
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 219, in get_subj_alt_name
        for name in ext.get_values_for_type(x509.DNSName)
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 175, in _dnsname_to_stdlib
        name = idna_encode(name)
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 167, in idna_encode
        import idna
        ImportError: No module named idna

        ERROR: Traceback (most recent call last):
        File "/root/shadowsocks/auto_block.py", line 289, in thread_db
        db_instance.auto_block_thread()
        File "/root/shadowsocks/auto_block.py", line 45, in auto_block_thread
        data = webapi.getApi('nodes')
        File "/root/shadowsocks/webapi_utils.py", line 39, in getApi
        raise Exception('network issue or server error!')
        Exception: network issue or server error!

        INFO: ShadowsocksR 3.4.0 mod by esdeathlove
        INFO: current process RLIMIT_NOFILE resource: soft 512000 hard 512000
        ERROR: Traceback (most recent call last):
        File "/root/shadowsocks/webapi_utils.py", line 23, in getApi
        timeout=10)
        File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 501, in get
        return self.request('GET', url, **kwargs)
        File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 488, in request
        resp = self.send(prep, **send_kwargs)
        File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 609, in send
        r = adapter.send(request, **kwargs)
        File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 423, in send
        timeout=timeout
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
        chunked=chunked)
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
        self._validate_conn(conn)
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
        conn.connect()
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/connection.py", line 333, in connect
        cert = self.sock.getpeercert()
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 343, in getpeercert
        'subjectAltName': get_subj_alt_name(x509)
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 219, in get_subj_alt_name
        for name in ext.get_values_for_type(x509.DNSName)
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 175, in _dnsname_to_stdlib
        name = idna_encode(name)
        File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 167, in idna_encode
        import idna
        ImportError: No module named idna

        ERROR: Traceback (most recent call last):
        File "/root/shadowsocks/web_transfer.py", line 660, in thread_db
        ping = webapi.getApi('func/ping')
        File "/root/shadowsocks/webapi_utils.py", line 39, in getApi
        raise Exception('network issue or server error!')
        Exception: network issue or server error!

        ^CTraceback (most recent call last):
        File "server.py", line 78, in main
        threadMain.join(10.0)
        File "/usr/lib64/python2.7/threading.py", line 962, in join
        self.__block.wait(delay, balancing)
        File "/usr/lib64/python2.7/threading.py", line 362, in wait
        _sleep(delay)
        KeyboardInterrupt
        INFO: loading config from user-config.json
        2020-03-01 13:10:11 INFO util.py:49 loading libcrypto from libcrypto.so.10
        2020-03-01 13:10:11 INFO asyncdns.py:324 dns server: [('100.100.2.136', 53), ('100.100.2.138', 53)]
        2020-03-01 13:10:11 INFO asyncdns.py:324 dns server: [('100.100.2.136', 53), ('100.100.2.138', 53)]

        okak 2020年3月2日, 16:42回复
        1. 小忆

          这个问题好像是上面代码缺了一个空格引起的

          小忆 2020年6月10日, 23:07回复
      3. okak

        不是kvm的,是openvz,服务商写明了不支持docker

        okak 2020年3月1日, 17:51回复
        1. 小忆

          那确实是不支持的,可以手动安装或者通过脚本安装。再使用防火墙端口转发。后期我看一下写一下相关教程

          小忆 2020年6月10日, 23:05回复
    2. 小忆

      脚本安装完成后,使用端口映射也可以。不复杂,有时间我写一下

      小忆 2020年3月1日, 17:35回复
发表新评论