Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions build/hydra-proxy.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
config,
lib,
pkgs,
...
}:

let
bannedUserAgentPatterns = [
"Chrome/129.0.0.0"
];
in
{
networking.firewall.allowedTCPPorts = [
80
Expand Down Expand Up @@ -43,6 +49,13 @@
'';

appendHttpConfig = ''
map $http_user_agent $badagent {
default 0;
${lib.concatMapStringsSep "\n" (pattern: ''
~${pattern} 1;
'') bannedUserAgentPatterns}
}

map $http_x_from $upstream {
default "anubis";
nix.dev-Uogho3gi "hydra-server";
Expand Down Expand Up @@ -89,6 +102,11 @@
locations."/" = {
proxyPass = "http://$upstream";
extraConfig = ''
if ($badagent) {
access_log /var/log/nginx/abuse.log;
return 403;
}

limit_req zone=hydra-server burst=7;
'';
};
Expand Down