nixos/systems/proxy/default.nix

89 lines
2.4 KiB
Nix
Raw Normal View History

2024-01-01 13:14:24 +01:00
{ hostname }:
2024-02-02 13:45:05 +01:00
{ inputs, pkgs, ... }:
{
2023-06-07 19:06:20 +02:00
hardware = {
az-raspi4-ethernet = {
2023-06-07 19:06:20 +02:00
enable = true;
hostname = hostname;
ip = "10.7.89.99";
};
};
2024-03-07 21:01:47 +01:00
zramSwap = {
enable = true;
2024-03-07 21:32:03 +01:00
writebackDevice = "/var/lib/zram_writeback";
2024-03-07 21:01:47 +01:00
};
2024-02-19 11:18:04 +01:00
profiles.az-server.enable = true;
2023-06-05 15:14:06 +02:00
services = {
2023-06-05 15:58:28 +02:00
az-acme-base.enable = true;
2023-06-05 15:14:06 +02:00
az-grav.enable = true;
2023-06-05 15:21:11 +02:00
az-haproxy.enable = true;
2023-06-05 15:23:53 +02:00
az-heimdall.enable = true;
2023-06-06 22:09:36 +02:00
az-restic-client-server = {
enable = true;
2024-01-01 14:33:03 +01:00
path = "/mnt/server-data";
tag = "proxy";
2023-06-06 22:09:36 +02:00
time = "00:00";
};
2023-06-05 15:14:06 +02:00
nginx = {
commonHttpConfig = ''
# Add HSTS header with preloading to HTTPS requests.
# Adding this header to HTTP requests is discouraged
# Enable CSP for your services.
#add_header Content-Security-Policy "script-src 'self'; object-src 'none'; base-uri 'none';" always;
2022-09-06 19:38:53 +02:00
2023-06-05 15:14:06 +02:00
# Minimize information leaked to other domains
add_header 'Referrer-Policy' 'origin-when-cross-origin';
2022-09-06 19:38:53 +02:00
2023-06-05 15:14:06 +02:00
# Disable embedding as a frame
add_header X-Frame-Options DENY;
2022-09-06 19:38:53 +02:00
2023-06-05 15:14:06 +02:00
# Prevent injection of code in other mime types (XSS Attacks)
add_header X-Content-Type-Options nosniff;
2022-09-06 19:38:53 +02:00
2023-06-05 15:14:06 +02:00
# Enable XSS protection of the browser.
# May be unnecessary when CSP is configured properly (see above)
add_header X-XSS-Protection "1; mode=block";
2022-09-06 19:38:53 +02:00
2023-06-05 15:14:06 +02:00
# This might create errors
proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
'';
recommendedProxySettings = true;
virtualHosts = {
"2li.ch" = {
serverAliases = [ "www.2li.ch" ];
enableACME = true;
forceSSL = true;
2024-02-02 13:45:05 +01:00
listen = [
{
port = 4433;
addr = "127.0.0.1";
ssl = true;
}
];
2023-06-05 15:14:06 +02:00
locations."/" = {
proxyPass = "http://127.0.0.1:8080";
proxyWebsockets = true; # needed if you need to use WebSocket
};
2022-09-06 19:38:53 +02:00
};
2023-06-05 15:14:06 +02:00
"heimdall.2li.ch" = {
enableACME = true;
forceSSL = true;
2024-02-02 13:45:05 +01:00
listen = [
{
port = 4433;
addr = "127.0.0.1";
ssl = true;
}
];
2023-06-05 15:14:06 +02:00
locations."/" = {
proxyPass = "http://127.0.0.1:8081";
proxyWebsockets = true; # needed if you need to use WebSocket
};
};
};
2022-09-06 19:38:53 +02:00
};
};
2022-02-28 21:19:55 +01:00
}