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