This repository has no description
4.5 kB
148 lines
1{ config, lib, pkgs, self, ... }:
2
3{
4 imports = [
5 self.inputs.stockholm.nixosModules.htgen
6 ];
7 services.nginx.virtualHosts.cyberlocker = {
8 serverAliases = [ "c.r" ];
9 locations."/".extraConfig = ''
10 client_max_body_size 4G;
11 proxy_set_header Host $host;
12 proxy_pass http://127.0.0.1:${toString config.krebs.htgen.cyberlocker.port};
13 '';
14 extraConfig = ''
15 add_header Access-Control-Allow-Origin * always;
16 add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
17 '';
18 };
19 services.nginx.virtualHosts.paste = {
20 serverAliases = [ "p.r" ];
21 locations."/".extraConfig = ''
22 client_max_body_size 4G;
23 proxy_set_header Host $host;
24 proxy_pass http://127.0.0.1:${toString config.krebs.htgen.paste.port};
25 '';
26 locations."/image".extraConfig = /* nginx */ ''
27 client_max_body_size 40M;
28
29 proxy_set_header Host $host;
30 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
31 proxy_set_header X-Forwarded-Proto $scheme;
32
33 proxy_pass http://127.0.0.1:${toString config.krebs.htgen.imgur.port};
34 proxy_pass_header Server;
35 '';
36 extraConfig = ''
37 add_header 'Access-Control-Allow-Origin' '*';
38 add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
39 '';
40 };
41 services.nginx.virtualHosts."c.krebsco.de" = {
42 enableACME = true;
43 addSSL = true;
44 serverAliases = [ "c.krebsco.de" ];
45 locations."/".extraConfig = ''
46 if ($request_method != GET) {
47 return 403;
48 }
49 proxy_set_header Host $host;
50 proxy_pass http://127.0.0.1:${toString config.krebs.htgen.cyberlocker.port};
51 '';
52 extraConfig = ''
53 add_header Access-Control-Allow-Origin * always;
54 add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
55 '';
56 };
57 services.nginx.virtualHosts."p.krebsco.de" = {
58 enableACME = true;
59 addSSL = true;
60 serverAliases = [ "p.krebsco.de" ];
61 locations."/".extraConfig = ''
62 if ($request_method = 'OPTIONS') {
63 return 204;
64 }
65 client_max_body_size 4G;
66 proxy_set_header Host $host;
67 proxy_set_header X-Forwarded-Proto $scheme;
68 proxy_pass http://127.0.0.1:${toString config.krebs.htgen.paste.port};
69 '';
70 locations."/form".extraConfig = ''
71 client_max_body_size 4G;
72 proxy_set_header Host $host;
73 proxy_pass http://127.0.0.1:${toString config.krebs.htgen.paste-form.port};
74 '';
75 locations."/image".extraConfig = ''
76 proxy_set_header Host $host;
77 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
78 proxy_set_header X-Forwarded-Proto $scheme;
79
80 proxy_pass http://127.0.0.1:${toString config.krebs.htgen.imgur.port};
81 proxy_pass_header Server;
82 '';
83 extraConfig = ''
84 add_header Access-Control-Allow-Headers Authorization always;
85 add_header Access-Control-Allow-Origin * always;
86 add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
87 '';
88 };
89
90 krebs.htgen.paste = {
91 port = 9081;
92 script = /* sh */ ''
93 (. ${pkgs.htgen-paste}/bin/htgen-paste)
94 '';
95 };
96
97 systemd.services.paste-gc = {
98 startAt = "daily";
99 serviceConfig = {
100 ExecStart = ''
101 ${pkgs.findutils}/bin/find /var/lib/htgen-paste/items -type f -mtime '+30' -exec rm {} \;
102 '';
103 User = "htgen-paste";
104 };
105 };
106
107 krebs.htgen.paste-form = {
108 port = 7770;
109 script = /* sh */ ''
110 export PATH=${lib.makeBinPath [
111 pkgs.curl
112 pkgs.gnused
113 ]}:$PATH
114 (. ${pkgs.writeScript "paste-form" ''
115 case "$Method" in
116 'POST')
117 ref=$(head -c $req_content_length | sed '0,/^\r$/d;$d' | curl -fSs --data-binary @- https://p.krebsco.de | sed '1d;s/^http:/https:/')
118
119 printf 'HTTP/1.1 200 OK\r\n'
120 printf 'Content-Type: text/plain; charset=UTF-8\r\n'
121 printf 'Server: %s\r\n' "$Server"
122 printf 'Connection: close\r\n'
123 printf 'Content-Length: %d\r\n' $(expr ''${#ref} + 1)
124 printf '\r\n'
125 printf '%s\n' "$ref"
126
127 exit
128 ;;
129 esac
130 ''})
131 '';
132 };
133 krebs.htgen.imgur = {
134 port = 7771;
135 script = /* sh */ ''
136 (. ${pkgs.htgen-imgur}/bin/htgen-imgur)
137 '';
138 };
139 krebs.htgen.cyberlocker = {
140 port = 7772;
141 script = /* sh */ ''
142 (. ${pkgs.htgen-cyberlocker}/bin/htgen-cyberlocker)
143 '';
144 };
145 krebs.iptables.tables.filter.INPUT.rules = [
146 { predicate = "-i retiolum -p tcp --dport 80"; target = "ACCEPT";}
147 ];
148}