blob: ad0e82289db1760922d3d326498ee0161a3b87f7 [file] [log] [blame]
# SPDX-FileCopyrightText: 2024 Clicks Codes
#
# SPDX-License-Identifier: GPL-3.0-only
{ lib, inputs, ... }:
{
nginx.http = let
_directory = listContents: root: {
inherit root listContents;
_type = "directory";
headers = null;
};
_redirect = permanent: to: {
inherit to permanent;
_type = "redirect";
headers = null;
};
_reverseProxy = protocol: host: port: {
inherit protocol host port;
_type = "reverseProxy";
headers = null;
};
in {
# Header Manipulation
addHeader = name: value: content: {
inherit name value content;
_type = "header";
};
unsafeAddCrossOriginHeader = lib.clicks.nginx.http.addHeader "Access-Control-Allow-Origin" "*";
# Location translatable directives
directory = _directory true;
privateDirectory = _directory false;
file = path: {
inherit path;
_type = "file";
};
redirect = _redirect false;
redirectPermanent = _redirect true;
reverseProxySecure = _reverseProxy "https";
reverseProxy = _reverseProxy "http";
status = code: {
inherit code;
_type = "status";
headers = null;
};
};
}