hitch: init at 1.4.8 + service + test (#39358)

Add the Hitch TLS reverse proxy as an option for TLS termination.
This commit is contained in:
Julien Langlois 2018-05-01 02:36:36 -07:00 committed by Jörg Thalheim
parent 164b580b36
commit 519b64592d
9 changed files with 227 additions and 0 deletions

View File

@ -1760,6 +1760,11 @@
github = "tftio";
name = "James Felix Black";
};
jflanglois = {
email = "yourstruly@julienlanglois.me";
github = "jflanglois";
name = "Julien Langlois";
};
jfrankenau = {
email = "johannes@frankenau.net";
github = "jfrankenau";

View File

@ -651,6 +651,7 @@
./services/web-servers/apache-httpd/default.nix
./services/web-servers/caddy.nix
./services/web-servers/fcgiwrap.nix
./services/web-servers/hitch/default.nix
./services/web-servers/jboss/default.nix
./services/web-servers/lighttpd/cgit.nix
./services/web-servers/lighttpd/collectd.nix

View File

@ -0,0 +1,108 @@
{ config, lib, pkgs, ...}:
let
cfg = config.services.hitch;
ocspDir = lib.optionalString cfg.ocsp-stapling.enabled "/var/cache/hitch/ocsp";
hitchConfig = with lib; pkgs.writeText "hitch.conf" (concatStringsSep "\n" [
("backend = \"${cfg.backend}\"")
(concatMapStrings (s: "frontend = \"${s}\"\n") cfg.frontend)
(concatMapStrings (s: "pem-file = \"${s}\"\n") cfg.pem-files)
("ciphers = \"${cfg.ciphers}\"")
("ocsp-dir = \"${ocspDir}\"")
"user = \"${cfg.user}\""
"group = \"${cfg.group}\""
cfg.extraConfig
]);
in
with lib;
{
options = {
services.hitch = {
enable = mkEnableOption "Hitch Server";
backend = mkOption {
type = types.str;
description = ''
The host and port Hitch connects to when receiving
a connection in the form [HOST]:PORT
'';
};
ciphers = mkOption {
type = types.str;
default = "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
description = "The list of ciphers to use";
};
frontend = mkOption {
type = types.either types.str (types.listOf types.str);
default = "[127.0.0.1]:443";
description = ''
The port and interface of the listen endpoint in the
+ form [HOST]:PORT[+CERT].
'';
apply = toList;
};
pem-files = mkOption {
type = types.listOf types.path;
default = [];
description = "PEM files to use";
};
ocsp-stapling = {
enabled = mkOption {
type = types.bool;
default = true;
description = "Whether to enable OCSP Stapling";
};
};
user = mkOption {
type = types.str;
default = "hitch";
description = "The user to run as";
};
group = mkOption {
type = types.str;
default = "hitch";
description = "The group to run as";
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = "Additional configuration lines";
};
};
};
config = mkIf cfg.enable {
systemd.services.hitch = {
description = "Hitch";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
preStart = ''
${pkgs.hitch}/sbin/hitch -t --config ${hitchConfig}
'' + (optionalString cfg.ocsp-stapling.enabled ''
mkdir -p ${ocspDir}
chown -R hitch:hitch ${ocspDir}
'');
serviceConfig = {
Type = "forking";
ExecStart = "${pkgs.hitch}/sbin/hitch --daemon --config ${hitchConfig}";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
Restart = "always";
RestartSec = "5s";
LimitNOFILE = 131072;
};
};
environment.systemPackages = [ pkgs.hitch ];
users.extraUsers.hitch.group = "hitch";
users.extraGroups.hitch = {};
};
}

View File

@ -297,6 +297,7 @@ in rec {
tests.graphite = callTest tests/graphite.nix {};
tests.hardened = callTest tests/hardened.nix { };
tests.hibernate = callTest tests/hibernate.nix {};
tests.hitch = callTest tests/hitch {};
tests.home-assistant = callTest tests/home-assistant.nix { };
tests.hound = callTest tests/hound.nix {};
tests.hocker-fetchdocker = callTest tests/hocker-fetchdocker {};

View File

@ -0,0 +1,33 @@
import ../make-test.nix ({ pkgs, ... }:
{
name = "hitch";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ jflanglois ];
};
machine = { config, pkgs, ... }: {
environment.systemPackages = [ pkgs.curl ];
services.hitch = {
enable = true;
backend = "[127.0.0.1]:80";
pem-files = [
./example.pem
];
};
services.httpd = {
enable = true;
documentRoot = ./example;
adminAddr = "noone@testing.nowhere";
};
};
testScript =
''
startAll;
$machine->waitForUnit('multi-user.target');
$machine->waitForUnit('hitch.service');
$machine->waitForOpenPort(443);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pzQ=
-----END PRIVATE KEY-----

View File

@ -0,0 +1 @@
We are all good!

View File

@ -0,0 +1,23 @@
{ stdenv, fetchurl, docutils, libev, openssl, pkgconfig }:
stdenv.mkDerivation rec {
version = "1.4.8";
name = "hitch-${version}";
src = fetchurl {
url = "https://hitch-tls.org/source/${name}.tar.gz";
sha256 = "1hqs5p69gr1lb3xldbrgq7d6d0vk4za0wpizlzybn98cv68acaym";
};
nativeBuildInputs = [ pkgconfig ];
buildInputs = [ docutils libev openssl ];
outputs = [ "out" "doc" "man" ];
meta = with stdenv.lib; {
description = "Hitch is a libev-based high performance SSL/TLS proxy by Varnish Software";
homepage = https://hitch-tls.org/;
license = licenses.bsd2;
maintainers = [ maintainers.jflanglois ];
platforms = platforms.linux;
};
}

View File

@ -5611,6 +5611,8 @@ with pkgs;
varnishPackages = varnish5Packages;
varnish = varnishPackages.varnish;
hitch = callPackage ../servers/hitch { };
venus = callPackage ../tools/misc/venus {
python = python27;
};