46 lines
1.1 KiB
Nix
46 lines
1.1 KiB
Nix
|
|
{ config, pkgs, lib, ... }:
|
||
|
|
|
||
|
|
{
|
||
|
|
# Common configuration shared between staging and prod
|
||
|
|
|
||
|
|
# This file contains nginx settings that are identical across environments
|
||
|
|
# Import this in both staging.nginx.nix and prod.nginx.nix
|
||
|
|
|
||
|
|
services.nginx = {
|
||
|
|
# Recommended settings
|
||
|
|
recommendedGzipSettings = true;
|
||
|
|
recommendedOptimisation = true;
|
||
|
|
recommendedProxySettings = true;
|
||
|
|
};
|
||
|
|
|
||
|
|
# Common location configurations that can be reused
|
||
|
|
# These are defined as library functions
|
||
|
|
lib.nginxLocations = {
|
||
|
|
# Standard root location with SSI support
|
||
|
|
rootLocation = {
|
||
|
|
index = "index.html";
|
||
|
|
tryFiles = "$uri $uri/ =404";
|
||
|
|
extraConfig = ''
|
||
|
|
# Enable Server Side Includes for navbar/footer includes
|
||
|
|
ssi on;
|
||
|
|
'';
|
||
|
|
};
|
||
|
|
|
||
|
|
# Private blog articles location with HTTP basic authentication
|
||
|
|
privateLocation = {
|
||
|
|
extraConfig = ''
|
||
|
|
auth_basic "Private Articles";
|
||
|
|
auth_basic_user_file /srv/nginx/.htpasswd;
|
||
|
|
|
||
|
|
# Enable Server Side Includes
|
||
|
|
ssi on;
|
||
|
|
'';
|
||
|
|
};
|
||
|
|
|
||
|
|
# Common extraConfig for custom 404
|
||
|
|
custom404 = ''
|
||
|
|
error_page 404 /404.html;
|
||
|
|
'';
|
||
|
|
};
|
||
|
|
}
|