This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

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