{ config, pkgs, lib, mkDomain, ... }:
{
  # Convos
  # The simplest way to use IRC in your browser

  services.convos = {
    enable = false; # user registration is borken. new major version (7) in unstable.
    reverseProxy = true;
    listenAddress = "127.0.0.1";
    listenPort = 44649;
  };
  services.nginx.virtualHosts.${mkDomain "convos"} = lib.mkIf config.services.convos.enable {
    forceSSL = true; # addSSL = true;
    enableACME = true; #useACMEHost = acmeDomain;
    locations."/" = {
      proxyPass = "http://127.0.0.1:${toString config.services.convos.listenPort}";
      proxyWebsockets = true;
      extraConfig = ''
        #proxy_redirect off;
        client_max_body_size 0;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Request-Base "$scheme://$host/";
        #proxy_set_header X-Real-IP $remote_addr;
        #proxy_set_header REMOTE-HOST $remote_addr;
      '';
    };
  };
}
