mio-ops/profiles/cryptpad.nix

77 lines
2.3 KiB
Nix
Raw Normal View History

2020-12-31 02:12:58 +00:00
# NixOps configuration for the hosts running a Cryptpad server
{ config, pkgs, lib, ... }:
{
services.cryptpad = {
2021-11-16 04:57:23 +00:00
enable = true; # Enable Cryptpad server
2020-12-31 02:12:58 +00:00
};
services.nginx = {
2021-11-16 04:57:23 +00:00
enable = true; # Enable Nginx
2020-12-31 02:12:58 +00:00
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
2021-11-16 04:57:23 +00:00
virtualHosts."pad.mcwhirter.io" = { # Cryptpad hostname
enableACME = true; # Use ACME certs
forceSSL = true; # Force SSL
2020-12-31 02:12:58 +00:00
locations = {
"/".proxyPass = "http://[::]:3000/";
"^~ /cryptpad_websocket" = {
proxyPass = "http://[::]:3000";
extraConfig = ''
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
'';
};
"^~ /customize.dist/" = {
2021-11-16 04:57:23 +00:00
# This is needed in order to prevent infinite recursion between /customize/ and the root
2020-12-31 02:12:58 +00:00
};
"^~ /customize/" = {
extraConfig = ''
rewrite ^/customize/(.*)$ $1 break;
'';
tryFiles = "/customize/$uri /customize.dist/$uri";
};
"/api/config" = {
proxyPass = "http://localhost:3000";
extraConfig = ''
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
'';
};
"^~ /block/" = {
extraConfig = ''
add_header Cache-Control max-age=0;
'';
tryFiles = "$uri =404";
};
2021-11-16 04:57:23 +00:00
"~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media|profile|contacts|todo|filepicker|debug|kanban|sheet|support|admin|notifications|teams)$" =
{
extraConfig = ''
rewrite ^(.*)$ $1/ redirect;
'';
};
2020-12-31 02:12:58 +00:00
};
#extraConfig = ''
# try_files /www/$uri /www/$uri/index.html /customize/$uri;
#'';
};
};
security.acme = {
acceptTerms = true;
2021-11-16 04:57:23 +00:00
certs = { "pad.mcwhirter.io".email = "craige@mcwhirter.io"; };
2020-12-31 02:12:58 +00:00
};
}