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