infrastructure/nixos/hosts/nginx/configuration.nix

92 lines
2.7 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;
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-06 17:41:05 +02:00
# virtualHosts."analytics.0x76.dev" = proxy "http://plausible.olympus:8000/";
2022-04-29 22:24:44 +02:00
virtualHosts."git.0x76.dev" = proxy "http://gitea.olympus:3000";
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;
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
# Headscale
virtualHosts."vpn.0x76.dev" = {
enableACME = true;
forceSSL = true;
locations = {
"/headscale." = {
extraConfig = ''
grpc_pass grpc://headscale.olympus:50443;
'';
priority = 1;
};
# "/metrics" = {
# proxyPass = "http://plausible.olympus:9090";
# extraConfig = ''
# allow 10.0.0.0/8;
# allow 100.64.0.0/16;
# deny all;
# '';
# priority = 2;
# };
"/" = {
proxyPass = "http://headscale.olympus:8080";
proxyWebsockets = true;
extraConfig = ''
keepalive_requests 100000;
keepalive_timeout 160s;
proxy_buffering off;
proxy_connect_timeout 75;
proxy_ignore_client_abort on;
proxy_read_timeout 900s;
proxy_send_timeout 600;
send_timeout 600;
'';
priority = 99;
};
};
};
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;
2021-10-18 21:37:56 +02:00
}