NixOS-Config/modules/system/services/server/nginx/default.nix

76 lines
2 KiB
Nix
Raw Normal View History

{ pkgs, config, ... }:
2024-10-09 03:36:08 -04:00
{
services.nginx = {
2024-08-24 22:16:51 -04:00
enable = true;
package = (pkgs.nginx.override {
modules = with pkgs.nginxModules; [ rtmp ];
});
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedProxySettings = true;
virtualHosts = {
2024-08-26 14:29:23 -04:00
# Landing page
"${config.secrets.jimDomain}" = {
2024-08-24 22:16:51 -04:00
enableACME = true;
addSSL = true;
root = "/var/www/Jimbo-Landing-Page";
2024-08-24 22:16:51 -04:00
locations = {
"/.well-known/matrix/client" = {
extraConfig = ''
2024-09-10 21:39:12 -04:00
default_type application/json;
return 200 '
{
"m.homeserver": {
"base_url": "https://matrix.${config.secrets.jimDomain}"
2024-09-10 21:39:12 -04:00
},
"m.identity_server": {
"base_url": "https://matrix.org"
},
"org.matrix.msc3575.proxy": {
"url": "https://matrix.${config.secrets.jimDomain}"
2024-09-10 21:39:12 -04:00
}
}';
'';
};
"/.well-known/matrix/server" = {
extraConfig = ''
2024-08-24 22:16:51 -04:00
default_type application/json;
return 200 '{"m.server": "matrix.${config.secrets.jimDomain}:443"}';
'';
};
2024-08-24 22:16:51 -04:00
};
};
};
appendConfig = ''
rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish all;
application stream {
record off;
live on;
allow play all;
2024-08-24 22:16:51 -04:00
hls on;
hls_path /var/www/Jimbo-Landing-Page/streams/hls/;
hls_fragment_naming system;
hls_fragment 3;
2024-08-24 22:16:51 -04:00
hls_playlist_length 40;
}
}
}
'';
};
# Allow Nginx to read and write to paths
2024-08-24 22:16:51 -04:00
systemd.services.nginx.serviceConfig = {
ReadWritePaths = [ "/var/www/Jimbo-Landing-Page/streams/hls/" ];
2024-08-24 22:16:51 -04:00
};
# Open HTTP and HTTPs ports
2024-09-10 21:39:12 -04:00
networking.firewall.allowedTCPPorts = [
80 443
];
2024-08-24 22:16:51 -04:00
}