V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
TommyLau
V2EX  ›  分享创造

自制 docker 版本 ocserv

  •  
  •   TommyLau · 2015-02-12 15:01:54 +08:00 · 4019 次点击
    这是一个创建于 3365 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近为了解决 iPhone 科学上网问题,研究了一下 ocserv,顺便做了一个 Docker 镜像,给有需要的同学使用。

    docker pull tommylau/ocserv
    docker run --name ocserv --privileged -p 443:443 -d tommylau/ocserv

    这种方式是最简单的,会自动创建用户名和密码均为 test 的用户,客户端直接使用 Cisco AnyConnect 连接服务器就可以了。

    更多的信息请参考:
    Docker Hub: https://registry.hub.docker.com/u/tommylau/ocserv/
    GitHub: https://github.com/TommyLau/docker-ocserv
    中文 Blog: http://tommy.net.cn/2015/02/12/deploy-openconnect-server-with-docker/
    第 1 条附言  ·  2015-02-14 22:53:27 +08:00
    建议使用 tommylau/ocserv-0.8.9 这个镜像,0.9.0 因为加入了 FreeRadius 会有断开后无法重连的问题:

    docker run --name ocserv --privileged -p 443:443 -p 443:443/udp -d tommylau/ocserv-0.8.9
    11 条回复    2015-09-03 08:44:53 +08:00
    luo362722353
        1
    luo362722353  
       2015-02-12 15:17:16 +08:00 via iPhone
    Good
    xiaojay
        2
    xiaojay  
       2015-02-12 15:49:02 +08:00
    谢谢分享

    blog rss订阅挂了?
    kacong
        3
    kacong  
       2015-02-12 16:28:24 +08:00
    mark, this is a good guide for newbies..
    i8s301a
        4
    i8s301a  
       2015-02-12 16:50:24 +08:00 via Android
    谢谢,研究学习一下
    zjgood
        5
    zjgood  
       2015-02-12 16:57:25 +08:00 via Android
    为毛iptables都不用配置呢?现在docker已经这么牛了啊
    TommyLau
        6
    TommyLau  
    OP
       2015-02-12 19:29:41 +08:00
    在官网说明 (http://www.infradead.org/ocserv/manual.html) 中,看到了如下一行:

    > The server maintains two connections/channels with the client. The main VPN channel is established over TCP and TLS. This is the control channel as well as the backup data channel. After its establishment a UDP channel using DTLS is initiated which serves as the main data channel. If the UDP channel fails to establish or is temporarily unavailable the backup channel over TCP/TLS is being used.

    所以,服务器开启的时候,最好再加上 -p 443:443/udp,比如:

    docker run --name ocserv --privileged -p 443:443 -p 443:443/udp -d tommylau/ocserv
    Eleutherios
        7
    Eleutherios  
       2015-02-13 09:19:06 +08:00
    @TommyLau 我觉得国内使用的话, 不加UDP没准会更好
    TommyLau
        8
    TommyLau  
    OP
       2015-02-13 09:24:47 +08:00
    @Eleutherios 按照官方的介绍的话,如果 UDP 连接失败的话,会自动跳回 TCP 的,不过考虑到国内到海外线路 UDP 丢包的严重性的话,也许不加 UDP 可能会更好。
    hezhile
        9
    hezhile  
       2015-02-14 17:47:15 +08:00
    请问 ocserv的端口可以改为443以外的吗?我想把ocserv跟shadowsocks放在同一台VPS上面 现在用的shadowsocks已经用了443端口。
    TommyLau
        10
    TommyLau  
    OP
       2015-02-14 22:52:22 +08:00
    @hezhile 可以参考 ocserv 官方的文档: http://www.infradead.org/ocserv/multihost.html

    比如,你可以把 shadowsocks 设置在 4443,然后 ocserv 设置在 4444,然后 sniproxy 跑在 443 上监听。然后用2个不同的域名来访问,比如 ss.yourhost.comoc.yourhost.com

    table TableName {
    # Match exact request hostnames
    ss.yourhost.com 127.0.0.1:4443
    oc.yourhost.com 127.0.0.1:4444
    }

    不过流量大的话,不建议这样使用。另外,建议使用 tommylau/ocserv-0.8.9 这个镜像,0.9.0 因为加入了 FreeRadius 会有断开后无法重连的问题,要把 ocserv 映射到主机的 4444 端口,可以这样操作:

    docker run --name ocserv --privileged -p 4444:443 -p 4444:443/udp -d tommylau/ocserv-0.8.9
    1etters
        11
    1etters  
       2015-09-03 08:44:53 +08:00
    这个要怎么修改路由表呢?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2303 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 06:52 · PVG 14:52 · LAX 23:52 · JFK 02:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.