ma nginx: add vpn-ws prototype

This commit is contained in:
makefu 2017-12-18 21:26:45 +01:00
parent af30864203
commit 1fff5ae372
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -0,0 +1,35 @@
{pkgs, options, ... }:
let
pkg = pkgs.vpn-ws;
uid = "nginx";
gid = "nginx";
ip = "${pkgs.iproute}/bin/ip";
in {
services.nginx.virtualHosts."euer.krebsco.de".locations."/vpn" = {
# TODO client auth
extraConfig = ''
uwsgi_pass unix:/run/vpn.sock;
include ${pkgs.nginx}/conf/uwsgi_params;
'';
};
networking.interfaces.vpnws = {
virtual = true;
virtualType = "tap";
};
systemd.services.vpnws = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
Restart = "always";
PrivateTmp = true;
ExecStartPre = pkgs.writeDash "vpnws-pre" ''
${ip} link set vpnws up
${ip} addr add 10.244.1.1/24 dev vpnws || :
'';
ExecStart = pkgs.writeDash "vpnws-start" ''
${pkg}/bin/vpn-ws --tuntap vpnws /run/vpn.sock
'';
};
};
}