1
0
Fork 0
dotfiles/system/nixos/nginx.nix

40 lines
1.1 KiB
Nix
Raw Normal View History

2023-03-06 09:21:34 +00:00
{ pkgs, ... }:
2023-03-05 22:51:30 +00:00
{
services.nginx = {
enable = true;
2023-03-06 09:21:34 +00:00
package = pkgs.nginxQuic;
2023-03-05 22:51:30 +00:00
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedBrotliSettings = true;
recommendedTlsSettings = true;
2023-03-13 22:28:01 +00:00
commonHttpConfig = ''
map $remote_addr $remote_addr_anon {
~(?P<ip>\d+\.\d+\.\d+)\. $ip.0;
~(?P<ip>[^:]+:[^:]+): $ip::;
default 0.0.0.0;
}
log_format combined_anon '$remote_addr_anon - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
2023-03-13 22:42:19 +00:00
access_log /var/log/nginx/access.log combined_anon buffer=32k flush=5m;
2023-03-13 22:28:01 +00:00
'';
2023-03-05 22:51:30 +00:00
};
2023-03-06 08:55:28 +00:00
networking.firewall.interfaces =
let
nginxTCPPorts = [ 80 443 ];
2023-03-06 09:45:35 +00:00
nginxUDPPorts = [ 443 ];
2023-03-06 08:55:28 +00:00
in
{
"enp1s0".allowedTCPPorts = nginxTCPPorts;
2023-03-06 09:45:35 +00:00
"enp1s0".allowedUDPPorts = nginxUDPPorts;
2023-03-06 08:55:28 +00:00
"tailscale0".allowedTCPPorts = nginxTCPPorts;
2023-03-06 09:45:35 +00:00
"tailscale0".allowedUDPPorts = nginxUDPPorts;
2023-03-06 08:55:28 +00:00
};
2023-03-05 22:51:30 +00:00
}