···
1
+
{ config, pkgs, lib, ... }:
7
+
cfg = config.services.ocserv;
12
+
options.services.ocserv = {
13
+
enable = mkEnableOption "ocserv";
19
+
Configuration content to start an OCServ server.
21
+
For a full configuration reference,please refer to the online documentation
22
+
(https://ocserv.gitlab.io/www/manual.html), the openconnect
23
+
recipes (https://github.com/openconnect/recipes) or `man ocserv`.
27
+
# configuration examples from $out/doc without explanatory comments.
28
+
# for a full reference please look at the installed man pages.
29
+
auth = "plain[passwd=./sample.passwd]"
32
+
run-as-user = nobody
33
+
run-as-group = nogroup
34
+
socket-file = /var/run/ocserv-socket
35
+
server-cert = certs/server-cert.pem
36
+
server-key = certs/server-key.pem
40
+
switch-to-tcp-timeout = 25
41
+
try-mtu-discovery = false
42
+
cert-user-oid = 0.9.2342.19200300.100.1.1
43
+
tls-priorities = "NORMAL:%SERVER_PRECEDENCE:%COMPAT:-VERS-SSL3.0"
45
+
min-reauth-time = 300
47
+
ban-reset-time = 1200
48
+
cookie-timeout = 300
49
+
deny-roaming = false
53
+
pid-file = /var/run/ocserv.pid
55
+
predictable-ips = true
56
+
default-domain = example.com
57
+
ipv4-network = 192.168.1.0
58
+
ipv4-netmask = 255.255.255.0
61
+
route = 10.10.10.0/255.255.255.0
62
+
route = 192.168.0.0/255.255.0.0
63
+
no-route = 192.168.5.0/255.255.255.0
64
+
cisco-client-compat = true
67
+
[vhost:www.example.com]
68
+
auth = "certificate"
69
+
ca-cert = certs/ca.pem
70
+
server-cert = certs/server-cert-secp521r1.pem
71
+
server-key = cersts/certs/server-key-secp521r1.pem
72
+
ipv4-network = 192.168.2.0
73
+
ipv4-netmask = 255.255.255.0
74
+
cert-user-oid = 0.9.2342.19200300.100.1.1
79
+
config = mkIf cfg.enable {
80
+
environment.systemPackages = [ pkgs.ocserv ];
81
+
environment.etc."ocserv/ocserv.conf".text = cfg.config;
83
+
security.pam.services.ocserv = {};
85
+
systemd.services.ocserv = {
86
+
description = "OpenConnect SSL VPN server";
87
+
documentation = [ "man:ocserv(8)" ];
88
+
after = [ "dbus.service" "network-online.target" ];
89
+
wantedBy = [ "multi-user.target" ];
93
+
PIDFile = "/var/run/ocserv.pid";
94
+
ExecStart = "${pkgs.ocserv}/bin/ocserv --foreground --pid-file /var/run/ocesrv.pid --config /etc/ocserv/ocserv.conf";
95
+
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";