{ pkgs, ... }:

{
  services.caddy = {
    enable = true;
    # globalConfig = ''
    #   servers {
    #     trusted_proxies static cloudflare
    #   }
    # '';
    virtualHosts."http://kazusa.icn.mizuki.guru".extraConfig = ''
      respond "우응" 200
    '';
    virtualHosts."designmerge.co.kr".extraConfig = ''
      reverse_proxy 127.0.0.1:1108
    '';
    virtualHosts."plutos.dazzle.st".extraConfig = ''
      reverse_proxy epc.hikari.mizuki.arpa:3000
    '';
    virtualHosts."kurumi.dazzle.st".extraConfig = ''
      respond 204
    '';
    virtualHosts."pluto.dazzle.st".extraConfig = ''
      respond 204
    '';
    virtualHosts."note.dazzle.st".extraConfig = ''
      respond 204
    '';
    virtualHosts."report.dazzle.st".extraConfig = ''
      respond 204
    '';

    package = pkgs.caddy.withPlugins {
      plugins = [
        "github.com/caddy-dns/cloudflare@v0.2.2"
        "github.com/aksdb/caddy-cgi/v2@v2.2.6"
        "github.com/shift72/caddy-geo-ip@v0.6.0"
        "github.com/lolPants/caddy-requestid@v1.1.2"
        "github.com/WeidiDeng/caddy-cloudflare-ip@v0.0.0-20231130002422-f53b62aa13cb"
        "github.com/caddyserver/ntlm-transport@v0.1.2"
        "github.com/ueffel/caddy-brotli@v1.6.0"
        "github.com/RussellLuo/caddy-ext/ratelimit@v0.3.0"
        "github.com/neodyme-labs/user_agent_parse@v0.0.1"
      ];
      hash = "sha256-YqOyHxPIKreCSkXfJUWTEFi+xOlIIiDqy3bYt7/A6Rg=";
    };
  };
}
