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