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