infrastructure/nixos/hosts/olympus/nginx/configuration.nix

138 lines
4 KiB
Nix
Raw Normal View History

2023-05-05 10:04:38 +02:00
{ pkgs, ... }:
2021-10-30 18:31:37 +02:00
let
2022-07-28 14:23:32 +02:00
clientConfig = {
2022-07-28 17:01:28 +02:00
"m.homeserver" = {
base_url = "https://chat.meowy.tech";
server_name = "meowy.tech";
};
"m.identity_server" = { };
2022-07-28 14:23:32 +02:00
};
serverConfig."m.server" = "chat.meowy.tech:443";
mkWellKnown = data: ''
add_header Content-Type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON data}';
'';
2022-10-11 14:11:17 +02:00
in {
2021-10-18 21:37:56 +02:00
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.05"; # Did you read the comment?
2021-10-19 02:02:35 +02:00
networking.firewall.allowedTCPPorts = [ 80 443 ];
2023-05-05 10:04:38 +02:00
# Generates vhosts for all hosts that have an `exposes` section
2023-05-11 13:27:59 +02:00
services.v.nginx.autoExpose = true;
2023-05-05 10:04:38 +02:00
2021-10-18 23:26:26 +02:00
services.nginx = {
2021-10-18 21:37:56 +02:00
enable = true;
2022-07-30 12:22:19 +02:00
statusPage = true;
2021-10-18 23:26:26 +02:00
recommendedProxySettings = true;
recommendedTlsSettings = true;
2022-05-15 10:54:26 +02:00
recommendedOptimisation = true;
2023-04-24 09:42:17 +02:00
recommendedBrotliSettings = true;
2022-12-06 14:28:03 +01:00
clientMaxBodySize = "500m";
2021-10-18 23:26:26 +02:00
2023-04-24 09:42:17 +02:00
package = pkgs.nginxMainline;
2022-05-08 02:13:44 +02:00
2023-05-04 15:14:36 +02:00
# Templated
2023-05-05 10:04:38 +02:00
virtualHosts = {
"pass.0x76.dev" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://vaultwarden.olympus:8222";
proxyWebsockets = true;
};
locations."/notifications/hub/negotiate" = {
proxyPass = "http://vaultwarden.olympus:8222";
proxyWebsockets = true;
};
locations."/notifications/hub" = {
proxyPass = "http://vaultwarden.olympus:3012";
proxyWebsockets = true;
};
2022-10-11 14:11:17 +02:00
};
2022-10-03 15:17:09 +02:00
# Meow
"meowy.tech" = {
enableACME = true;
forceSSL = true;
locations."/".extraConfig = ''
add_header Content-Type 'text/html; charset=UTF-8';
return 200 '<h1>meow</h1>';
2023-04-05 16:31:20 +02:00
'';
locations."= /.well-known/matrix/client".extraConfig =
mkWellKnown clientConfig;
locations."= /.well-known/matrix/server".extraConfig =
mkWellKnown serverConfig;
2023-04-05 16:31:20 +02:00
};
"chat.meowy.tech" = {
enableACME = true;
forceSSL = true;
locations."/".extraConfig = ''
return 307 https://element.chat.meowy.tech;
'';
locations."/_matrix".proxyPass = "http://synapse.olympus:8008";
locations."/_synapse/client".proxyPass = "http://synapse.olympus:8008";
locations."/_synapse/admin" = {
# Allow only local and my own IPs
extraConfig = ''
allow 127.0.0.1;
allow 10.42.42.0/23;
allow 192.168.0.0/23;
allow 80.60.83.220;
2023-05-21 10:28:06 +02:00
allow 83.128.154.23;
allow 195.85.167.32/29;
deny all;
'';
proxyPass = "http://synapse.olympus:8008";
};
};
"element.chat.meowy.tech" = {
enableACME = true;
forceSSL = true;
2022-07-28 17:01:28 +02:00
root = pkgs.element-web.override {
conf = {
default_server_config = clientConfig;
show_labs_settings = true;
brand = "chat.meowy.tech";
};
2022-07-28 17:01:28 +02:00
};
};
"cinny.chat.meowy.tech" = {
enableACME = true;
forceSSL = true;
2022-10-03 15:17:09 +02:00
root = pkgs.cinny.override {
conf = {
defaultHomeserver = 0;
allowCustomHomeservers = false;
homeserverList = [ "chat.meowy.tech" ];
};
2022-10-03 15:17:09 +02:00
};
};
"admin.chat.meowy.tech" = {
enableACME = true;
forceSSL = true;
root = pkgs.synapse-admin;
};
};
2021-10-18 21:37:56 +02:00
};
2021-10-18 23:31:35 +02:00
2022-03-31 12:25:45 +02:00
security.acme.defaults.email = "victorheld12@gmail.com";
2021-10-18 23:32:11 +02:00
security.acme.acceptTerms = true;
2021-12-12 15:51:56 +01:00
security.acme.preliminarySelfsigned = true;
2022-07-30 12:22:19 +02:00
services.prometheus.exporters = {
nginx = {
enable = true;
openFirewall = true;
};
};
2021-10-18 21:37:56 +02:00
}