stockholm/lass/2configs/paste.nix

147 lines
4.4 KiB
Nix
Raw Normal View History

2017-04-11 19:39:57 +00:00
{ config, pkgs, ... }:
with import <stockholm/lib>;
{
2021-08-25 10:05:18 +00:00
services.nginx.virtualHosts.cyberlocker = {
serverAliases = [ "c.r" ];
locations."/".extraConfig = ''
client_max_body_size 4G;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:${toString config.krebs.htgen.cyberlocker.port};
'';
extraConfig = ''
2023-09-03 10:09:51 +00:00
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
2021-08-25 10:05:18 +00:00
'';
};
2017-04-11 19:39:57 +00:00
services.nginx.virtualHosts.paste = {
serverAliases = [ "p.r" ];
locations."/".extraConfig = ''
client_max_body_size 4G;
2017-04-11 19:39:57 +00:00
proxy_set_header Host $host;
2020-09-27 13:38:10 +00:00
proxy_pass http://127.0.0.1:${toString config.krebs.htgen.paste.port};
'';
locations."/image".extraConfig = /* nginx */ ''
client_max_body_size 40M;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:${toString config.krebs.htgen.imgur.port};
proxy_pass_header Server;
2017-04-11 19:39:57 +00:00
'';
2021-08-25 10:05:35 +00:00
extraConfig = ''
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
'';
2017-04-11 19:39:57 +00:00
};
2021-08-26 07:58:42 +00:00
services.nginx.virtualHosts."c.krebsco.de" = {
enableACME = true;
addSSL = true;
serverAliases = [ "c.krebsco.de" ];
locations."/".extraConfig = ''
if ($request_method != GET) {
return 403;
}
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:${toString config.krebs.htgen.cyberlocker.port};
'';
extraConfig = ''
2023-09-03 10:09:51 +00:00
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
2021-08-26 07:58:42 +00:00
'';
};
services.nginx.virtualHosts."p.krebsco.de" = {
enableACME = true;
addSSL = true;
2019-04-13 19:41:58 +00:00
serverAliases = [ "p.krebsco.de" ];
locations."/".extraConfig = ''
2023-09-03 10:09:51 +00:00
if ($request_method = 'OPTIONS') {
return 204;
}
client_max_body_size 4G;
2019-04-13 19:41:58 +00:00
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
2020-09-27 13:38:10 +00:00
proxy_pass http://127.0.0.1:${toString config.krebs.htgen.paste.port};
'';
locations."/form".extraConfig = ''
client_max_body_size 4G;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:${toString config.krebs.htgen.paste-form.port};
'';
2020-09-27 13:38:10 +00:00
locations."/image".extraConfig = ''
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:${toString config.krebs.htgen.imgur.port};
proxy_pass_header Server;
2019-04-13 19:41:58 +00:00
'';
2021-08-25 10:05:35 +00:00
extraConfig = ''
2023-09-03 10:09:51 +00:00
add_header Access-Control-Allow-Headers Authorization always;
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
2021-08-25 10:05:35 +00:00
'';
2019-04-13 19:41:58 +00:00
};
2020-09-27 13:38:10 +00:00
2017-04-11 19:39:57 +00:00
krebs.htgen.paste = {
port = 9081;
2023-04-28 21:11:21 +00:00
script = /* sh */ ''
(. ${pkgs.htgen-paste}/bin/htgen-paste)
'';
2017-04-11 19:39:57 +00:00
};
2022-08-10 12:41:04 +00:00
systemd.services.paste-gc = {
startAt = "daily";
serviceConfig = {
ExecStart = ''
${pkgs.findutils}/bin/find /var/lib/htgen-paste/items -type f -mtime '+30' -exec rm {} \;
'';
User = "htgen-paste";
};
};
krebs.htgen.paste-form = {
port = 7770;
script = /* sh */ ''
export PATH=${makeBinPath [
pkgs.curl
pkgs.gnused
]}:$PATH
(. ${pkgs.writeScript "paste-form" ''
case "$Method" in
'POST')
ref=$(head -c $req_content_length | sed '0,/^\r$/d;$d' | curl -fSs --data-binary @- https://p.krebsco.de | sed '1d;s/^http:/https:/')
printf 'HTTP/1.1 200 OK\r\n'
printf 'Content-Type: text/plain; charset=UTF-8\r\n'
printf 'Server: %s\r\n' "$Server"
printf 'Connection: close\r\n'
printf 'Content-Length: %d\r\n' $(expr ''${#ref} + 1)
printf '\r\n'
printf '%s\n' "$ref"
exit
;;
esac
''})
'';
};
2020-09-27 13:38:10 +00:00
krebs.htgen.imgur = {
port = 7771;
script = /* sh */ ''
(. ${pkgs.htgen-imgur}/bin/htgen-imgur)
'';
};
2021-08-25 10:05:18 +00:00
krebs.htgen.cyberlocker = {
port = 7772;
script = /* sh */ ''
(. ${pkgs.htgen-cyberlocker}/bin/htgen-cyberlocker)
'';
};
2017-04-11 19:39:57 +00:00
krebs.iptables.tables.filter.INPUT.rules = [
{ predicate = "-i retiolum -p tcp --dport 80"; target = "ACCEPT";}
];
}