helm/modules/services/nginx.nix

48 lines
1.4 KiB
Nix
Raw Permalink Normal View History

{ config, options, lib, pkgs, ... }:
2020-03-28 22:48:43 -07:00
with lib;
with lib.my;
let cfg = config.modules.services.nginx;
in {
2020-03-28 22:48:43 -07:00
options.modules.services.nginx = {
enable = mkBoolOpt false;
2020-03-28 22:48:43 -07:00
};
config = mkIf cfg.enable {
2020-03-28 22:48:43 -07:00
networking.firewall.allowedTCPPorts = [ 80 443 ];
2019-11-17 22:24:50 -08:00
user.extraGroups = [ "nginx" ];
2020-03-28 22:48:43 -07:00
services.nginx = {
enable = true;
2019-11-17 22:24:50 -08:00
2020-03-28 22:48:43 -07:00
# Use recommended settings
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
2021-01-30 14:07:52 -08:00
# Reduce the permitted size of client requests, to reduce the likelihood
# of buffer overflow attacks. This can be tweaked on a per-vhost basis, as
# needed.
clientMaxBodySize = "128k"; # default 10m
2021-01-30 14:07:52 -08:00
commonHttpConfig = ''
client_body_buffer_size 4k; # default: 8k
large_client_header_buffers 2 4k; # default: 4 8k
'';
2020-03-28 22:48:43 -07:00
};
2019-11-17 22:24:50 -08:00
};
}
# Helpful nginx snippets
#
# Set expires headers for static files and turn off logging.
# location ~* ^.+\.(js|css|swf|xml|txt|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|r ss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav |bmp|rtf)$ {
# access_log off; log_not_found off; expires 30d;
# }
#
# Deny all attempts to access PHP Files in the uploads directory
# location ~* /(?:uploads|files)/.*\.php$ {
# deny all;
# }