haccfiles/configuration/server/cdn/cdn-lb.nix
hexchen 4fae006a64 livecdn: fix CORS
fucking CORS FUCK FUCK FUCK FUCK FUCK it's the absolute WORST
2020-12-02 18:30:51 +00:00

26 lines
585 B
Nix

{config, lib, pkgs, ...}:
{
imports = [
./common.nix
];
services.nginx = {
virtualHosts."${config.networking.hostName}.live.hacc.media" = {
locations = {
"/" = {
return = "301 \"https://$cdnhosts$request_uri\"";
extraConfig = ''
auth_basic off;
add_header 'Access-Control-Allow-Origin' '*';
'';
};
};
};
appendHttpConfig = ''
split_clients "$remote_addr" $cdnhosts {
50% "cdn-node-1.live.hacc.media";
50% "cdn-node-2.live.hacc.media";
}
'';
};
}