infrastructure/nixos/hosts/nginx/configuration.nix

70 lines
2.5 KiB
Nix
Raw Normal View History

2021-10-18 21:37:56 +02:00
{ config, pkgs, ... }:
2021-10-30 18:31:37 +02:00
let
2021-11-21 21:56:17 +01:00
proxy = url: {
2021-10-30 18:31:37 +02:00
enableACME = true;
forceSSL = true;
locations."/" = {
2021-11-21 21:56:17 +01:00
proxyPass = url;
2021-10-30 18:31:37 +02:00
proxyWebsockets = true;
};
};
2022-03-31 12:25:45 +02:00
k8s_proxy = proxy "http://10.42.42.150:8000/";
2022-05-06 17:41:05 +02:00
in
{
2021-10-19 02:02:35 +02:00
networking.hostName = "nginx";
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?
# Additional packages
2021-10-25 12:50:04 +02:00
environment.systemPackages = with pkgs; [ ];
2021-10-18 21:37:56 +02:00
2021-10-19 02:02:35 +02:00
networking.firewall.allowedTCPPorts = [ 80 443 ];
2021-10-18 23:26:26 +02:00
services.nginx = {
2021-10-18 21:37:56 +02:00
enable = true;
2021-10-18 23:26:26 +02:00
recommendedProxySettings = true;
recommendedTlsSettings = true;
2022-05-15 10:54:26 +02:00
recommendedOptimisation = true;
2021-10-18 23:26:26 +02:00
2022-05-08 02:13:44 +02:00
package = pkgs.nginxMainline.override {
modules = with pkgs.nginxModules; [ brotli ];
};
2021-11-21 21:56:17 +01:00
# Reverse Proxies
2022-04-29 22:24:44 +02:00
virtualHosts."ha.0x76.dev" = proxy "http://home-assistant.olympus:8123/";
2021-12-12 15:51:56 +01:00
virtualHosts."zookeeper-dev.0x76.dev" = proxy "http://eevee.olympus:8085/";
2022-05-15 01:24:06 +02:00
virtualHosts."md.0x76.dev" = proxy "http://hedgedoc.olympus:3000/";
2022-04-29 22:24:44 +02:00
virtualHosts."git.0x76.dev" = proxy "http://gitea.olympus:3000";
2022-05-15 10:54:26 +02:00
virtualHosts."o.0x76.dev" = proxy "http://minio.olympus:9000";
2021-11-12 09:43:50 +01:00
2021-10-30 18:31:37 +02:00
# Kubernetes endpoints
2021-11-03 00:52:39 +01:00
virtualHosts."0x76.dev" = k8s_proxy;
2022-05-18 12:05:23 +02:00
virtualHosts."id.0x76.dev" = k8s_proxy;
2021-10-30 18:31:37 +02:00
virtualHosts."zookeeper.0x76.dev" = k8s_proxy;
virtualHosts."wooloofan.club" = k8s_proxy;
virtualHosts."whoami.wooloofan.club" = k8s_proxy;
2022-05-06 17:41:05 +02:00
2021-10-18 21:37:56 +02:00
};
2021-10-18 23:31:35 +02:00
2022-05-16 14:17:45 +02:00
services.nginx.commonHttpConfig = ''
brotli on;
brotli_comp_level 6;
brotli_static on;
brotli_types application/atom+xml application/javascript application/json application/rss+xml
application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype
application/x-font-ttf application/x-javascript application/xhtml+xml application/xml
font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon
image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml;
'';
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;
2021-10-18 21:37:56 +02:00
}