Giter Club home page Giter Club logo

ocserv-docker's Introduction

用途

因为安装一个 Open Connect 的步骤实在太麻烦了, 特别对于新手, 所以特意参考了 jpetazzo 的 dockvpn 弄了一个 ocserv 的. 此项目的原因和一点点介绍可见 使用 ocserv-docker 享受自由网络

有啥问题可以直接 @wyatt_pan

简单部署

安装好 Docker 1.0+ 并且正常启动 Docker 后:

  • cd ~;git clone https://github.com/wppurking/ocserv-docker.git : 将当前 repo 下载, 拥有可调整的 ocserv.conf 配置文件以及 ocpasswd 用户密码文件
  • docker run -d --privileged --name ocserv-docker -v ~/ocserv-docker/ocserv:/etc/ocserv -p 443:443/tcp wppurking/ocserv : Box 自动下载. ocserv 的一些功能需要 Docker 在 privileged 权限下处理
  • docker logs ocserv-docker : 查看运行日志, 检查是否正常运行(可重复执行).
listening (TCP) on 0.0.0.0:443...
listening (TCP) on [::]:443...
listening (UDP) on 0.0.0.0:443...
listening (UDP) on [::]:443...

构建部署

构建自己本地的 images, 计算自己的 ssl key (自签名). 可以避免 N 多人使用一个证书的问题.

  • cd ~ && git clone https://github.com/wppurking/ocserv-docker.git : 将当前 repo 下载, 拥有可调整的 ocserv.conf 配置文件以及 ocpasswd 用户密码文件
  • cd ~/ocserv-docker && docker build --no-cache -t ocserv-docker . : 在 ocserv-docker 目录下, 重新构建全新的镜像使用. (例: 版本更新, 重新生成证书)
  • docker run -d --privileged --name ocserv-docker -v ~/ocserv-docker/ocserv:/etc/ocserv -p 443:443/tcp ocserv-docker : ocserv 的一些功能需要 Docker 在 privileged 权限下处理
  • docker logs ocserv-docker : 查看运行日志, 检查是否正常运行(可重复执行).

使用

  • 初始化好的两个账户: wyatt:616 holly:525
  • 如果主服务器上开启了 iptables, 一定要记得将 443 端口的 tcp 与 udp 都开放
  • 已经做了其能够处理的下发路由数量 (ocserv.conf 中, 感谢: kevinzhow 的 route.ship_cook.rb )
  • 接下来 就是 AnyConnect 的客户端了. Win, Mac, Linux Link1 (Cisco 官方需要注册...), iOS, Android
  • 因为我们自己生成的 CA 证书是没有权威组织认证的, 所以 AnyConnect 需要接受这些 "不信任的 VPN" :P

自定义证书, 密钥

因为是构建一个独立的 box 进行分发, 方便快速部署一个 ocserv, 所以将证书, 密钥, 用户都集成在里面了, 此刻方便使用. 如果对于有担心的, 可以 docker run -t -i wppurking/ocserv bash 进入到 box 中使用 certtool 重新进行处理, 具体操作步骤参考 [原创]linode vps debian7.5安装配置ocserv(OpenConnect server)

证书是在 Docker Build 的过程中自动生成的, 其生成的目的地为 /opt/certs 成功更换 certs 的例子

TODO: 自签名客户端证书登陆

用户名

为了使新手能够最快的使用上 AnyConnect (也方便我自己同一设备能方便的链接多个不同地域的 VPS) 我预先设置了两个初始化的账号密码, 但同时将用于提供账号密码的 ocserv/ocpasswd 文件放在 Box 外面, 运行 Container 时使用 Volume 挂在进去, 这样方便熟悉 Docker 的用户能够方便的 使用 ocpasswd 命令修改或者重新生成自己的用户密码.

提供一个非常简单的更换密码操作, 复制命令就好了(建立在按照上面的操作基础上哈):

新添加用户

$> docker exec -it $(docker ps -a | grep vpn_run | awk '{print $1}') ocpasswd yourname
$> Enter password:
$> Re-enter password:

这个的原理是借用 docker 运行中的 container , 在其里面运行 ocpasswd 改变 Volumn 进去的 ./ocserv/ocpasswd 文件内容, 所以当你运行完这行命令, 本机(非 container 中)的 ./ocserv/ocpasswd 的文件内容会真实发生变化

清理掉预设的两个用户名

直接打开 ./ocserv/ocpasswd 删掉 wyatt/holly 开头的两行就好了.

信息

  • Box Size: 164 MB (原来是 380+ MB, 基础镜像缩减)
  • 基础 Box: ubuntu:trusty
  • 测试过的环境:
    • [Linode 1G Ubuntu 14.04 LTS]
    • [Vultr 768MB Ubuntu 14.04 LTS]
    • [DigitalOcean 512MB Docker 1.2.0 on Ubuntu 14.04]

Refs

问题

大家最近连接上 ocserv 就断开, 我猜测因为有比较多的人使用同一个 Docker Image 使得太多人使用同一个证书, 然后我做了处理,

至少我的几台服务器已经正常, 不会断开了. 请大家 docker rmi wppurking/ocserv 然后再执行运行的命令下载最新的 image, 如果有条件自己 build 以下或者使用自己的证书即可.

关于限速, 我想应该是网络的干扰. 我部署的服务器 ( 1.5 MB/s 大概 12 Mbps) 如下:

AnyConnect

如果你网络好的话, 那么可以看到如下的情况 ( 7.1MB/s 的峰值, 56.8 Mbps) :

AnyConnect Speed

ocserv-docker's People

Contributors

5aaee9 avatar catatnight avatar harukama avatar hongqn avatar krizex avatar wppurking avatar wyattpan avatar zen9073 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ocserv-docker's Issues

ocserv.conf 文件错误, 导致 mac 客户端连接不上. 提示配置错误 The VPN configuration received from the secure gateway is invalid

使用 mac 上的 any connect 4.0 报错 The VPN configuration received from the secure gateway is invalid.
原因是
ocserv.conf 中间第 444 以及 445 行 格式不对
https://github.com/wppurking/ocserv-docker/blob/master/ocserv/ocserv.conf#L444
https://github.com/wppurking/ocserv-docker/blob/master/ocserv/ocserv.conf#L445
应该是
route = 60.0.0.0/255.0.0.0
route = 63.0.0.0/255.0.0.0

修改之后就不报错了.

English translation:

On Mac, any connect 4.0 shows the error 'The VPN configuration received from the secure gateway is invalid'
It results from a bug in the ocserv.conf.
The route rules on line 444 and 445 in file ocserv.conf are misspelled.
It should be
route = 60.0.0.0/255.0.0.0
route = 63.0.0.0/255.0.0.0

After the modification, the error disappears.

能否写一个在K8S 上部署的yaml

我这边有一个k8s 的公网cluster 想创建这个ocserv server但是k8s 这边开两个443 和443/udp 不知道怎么搞,

证书可以不用自己生成吗?

docker 1.7 docker: "run" requires a minimum of 1 argument.

[root@localhost ~]# docker run -d --privileged -v ~/ocserv-docker/ocserv:/etc/ocserv -p 443:443/tcp
docker: "run" requires a minimum of 1 argument.
See 'docker run --help'.

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

替换证书失败

你好。我参照您在 twitter 上的回复,按照这样的方式替换证书,但是执行了这句命令后,启动container失败。

docker run -d --privileged -v ~/ocserv-docker/ocserv:/etc/ocserv -v ~/ocserv-docker/ssl:/opt/certs -p 5677:5677/tcp wppurking/ocserv

~/ocserv-docker/ssl 目录下存放的是我自己的SSL证书。

如果移除 ssl 证书挂载,则可以成功启动 container

还有,想请教下,为什么我进入 container 后,无法找到 ocserv.conf 这个文件,我的 container 内的/etc/ocserv目录是空的?

谢谢!

使用证书会碰到的问题

改用证书后,由于0.8.6的config文件以及本项目的config文件中的session-control = true,会导致worker进程退出。
具体参见[http://bitinn.net/11084/#comment-452257]

dependency issue caused by new version of ocserv

As ocserv upgraded to 0.11.0, this image cannot be successfully built due to lack of dependencies.
ocserv 升级到 0.11.0 了,docker build 在编译 ocserv 阶段由于缺乏依赖失败。

checking for LIBPROTOBUF_C... no
checking for libprotobuf-c... no
configure: WARNING: ***
*** libprotobuf-c was not found.
***
checking for libev... no
configure: error: ***
*** libev4 was not found.
***

ocserv error 2 (No such file or directory) calling stat for '/etc/ocserv/ocserv.conf

我用k8s创建这个container 下面是我的yaml文件:

apiVersion: v1
kind: Service
metadata:
name: ocservsv
labels:
app: ocservapp
spec:
type: NodePort
ports:

  • port: 443
    selector:
    app: ocservapp
    type: LoadBalancer

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-ocservcontainer
labels:
app: ocservapp
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: azurescea

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: my-ocserv-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: ocservapp
spec:
containers:
- name: ocservcontainer
image: wppurking/ocserv-docker
securityContext:
privileged: true
ports:
- containerPort: 443
name: ocservtcp443
- containerPort: 443
name: ocservudp443
protocol: UDP
volumeMounts:
- name: ocserv-persistent-storage
mountPath: /etc/ocserv
volumes:
- name: ocserv-persistent-storage
persistentVolumeClaim:
claimName: pvc-ocservcontainer

但是创建完成之后日志会提示这个错误:
net.ipv4.ip_forward = 1
ocserv error 2 (No such file or directory) calling stat for '/etc/ocserv/ocserv.conf'

gnutls库版本过低

贡献者你好,发现 Dockerfile 在构建时会报如下错误:

checking for LIBNETTLE... yes
checking for LIBGNUTLS... no
configure: error: Package requirements (gnutls >= 3.3.0) were not met:

Requested 'gnutls >= 3.3.0' but version of GnuTLS is 3.2.11
You may find new versions of GnuTLS at http://www.gnutls.org/

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBGNUTLS_CFLAGS
and LIBGNUTLS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

应该是新版本的 ocserv 要求了更高版本的 GnuTLs 导致的. ubuntu:trusty 的 apt 提供的GnuTLs版本是2.9.x

把使用的 ubuuntu 镜像换成 latest 就可以正常构建了(version 3.6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.