Compare commits
11 Commits
568d6ccfb1
...
6a46388d68
Author | SHA1 | Date |
---|---|---|
Egor Savkin | 6a46388d68 | |
Egor Savkin | a6f30cff27 | |
Egor Savkin | f083672e66 | |
Egor Savkin | f46adfd8d3 | |
Egor Savkin | 694d908339 | |
Sébastien Bourdeauducq | 635f90f0c7 | |
Sébastien Bourdeauducq | 8a187ba5b9 | |
Sébastien Bourdeauducq | 9383227c5b | |
Sébastien Bourdeauducq | 233998b8f3 | |
Sébastien Bourdeauducq | 90a6b84c09 | |
Sébastien Bourdeauducq | 23e1fa029a |
|
@ -6,6 +6,8 @@ let
|
||||||
netifLan = "enp5s0f1";
|
netifLan = "enp5s0f1";
|
||||||
netifWifi = "wlp6s0";
|
netifWifi = "wlp6s0";
|
||||||
netifSit = "henet0";
|
netifSit = "henet0";
|
||||||
|
netifAlt = "alt0";
|
||||||
|
netifAltVlan = "vlan0";
|
||||||
hydraWwwOutputs = "/var/www/hydra-outputs";
|
hydraWwwOutputs = "/var/www/hydra-outputs";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -176,11 +178,20 @@ in
|
||||||
iptables -w -A block-insecure-devices -m mac --mac-source d8:9c:67:ab:83:e7 -j DROP # HP printer, wifi
|
iptables -w -A block-insecure-devices -m mac --mac-source d8:9c:67:ab:83:e7 -j DROP # HP printer, wifi
|
||||||
iptables -w -A block-insecure-devices -m mac --mac-source f4:39:09:f7:3c:d7 -j DROP # HP printer, ethernet
|
iptables -w -A block-insecure-devices -m mac --mac-source f4:39:09:f7:3c:d7 -j DROP # HP printer, ethernet
|
||||||
iptables -w -A FORWARD -j block-insecure-devices
|
iptables -w -A FORWARD -j block-insecure-devices
|
||||||
|
|
||||||
|
iptables -w -N pccw-sucks
|
||||||
|
iptables -A pccw-sucks -o ${netifSit} -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1440
|
||||||
|
iptables -A pccw-sucks -o ${netifAlt} -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1380
|
||||||
|
iptables -w -A FORWARD -j pccw-sucks
|
||||||
'';
|
'';
|
||||||
extraStopCommands = ''
|
extraStopCommands = ''
|
||||||
iptables -w -D FORWARD -j block-insecure-devices 2>/dev/null|| true
|
iptables -w -D FORWARD -j block-insecure-devices 2>/dev/null|| true
|
||||||
iptables -w -F block-insecure-devices 2>/dev/null|| true
|
iptables -w -F block-insecure-devices 2>/dev/null|| true
|
||||||
iptables -w -X block-insecure-devices 2>/dev/null|| true
|
iptables -w -X block-insecure-devices 2>/dev/null|| true
|
||||||
|
|
||||||
|
iptables -w -D FORWARD -j pccw-sucks 2>/dev/null|| true
|
||||||
|
iptables -w -F pccw-sucks 2>/dev/null|| true
|
||||||
|
iptables -w -X pccw-sucks 2>/dev/null|| true
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
sits."${netifSit}" = {
|
sits."${netifSit}" = {
|
||||||
|
@ -193,14 +204,14 @@ in
|
||||||
addresses = [{ address = "2001:470:18:390::2"; prefixLength = 64; }];
|
addresses = [{ address = "2001:470:18:390::2"; prefixLength = 64; }];
|
||||||
routes = [{ address = "::"; prefixLength = 0; }];
|
routes = [{ address = "::"; prefixLength = 0; }];
|
||||||
};
|
};
|
||||||
greTunnels.alt0 = {
|
greTunnels."${netifAlt}" = {
|
||||||
dev = netifWan;
|
dev = netifWan;
|
||||||
remote = "103.206.98.1";
|
remote = "103.206.98.1";
|
||||||
local = "94.190.212.123";
|
local = "94.190.212.123";
|
||||||
ttl = 255;
|
ttl = 255;
|
||||||
type = "tun";
|
type = "tun";
|
||||||
};
|
};
|
||||||
interfaces.alt0 = {
|
interfaces."${netifAlt}" = {
|
||||||
ipv4.addresses = [
|
ipv4.addresses = [
|
||||||
{
|
{
|
||||||
address = "103.206.98.227";
|
address = "103.206.98.227";
|
||||||
|
@ -216,13 +227,36 @@ in
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
greTunnels.intl0 = {
|
||||||
|
dev = netifWan;
|
||||||
|
remote = "5.78.16.0";
|
||||||
|
local = "94.190.212.123";
|
||||||
|
ttl = 255;
|
||||||
|
type = "tun";
|
||||||
|
};
|
||||||
|
interfaces.intl0 = {
|
||||||
|
ipv4.addresses = [
|
||||||
|
{
|
||||||
|
address = "5.78.16.0";
|
||||||
|
prefixLength = 32;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
ipv4.routes = [
|
||||||
|
{
|
||||||
|
address = "0.0.0.0";
|
||||||
|
prefixLength = 0;
|
||||||
|
via = "5.78.16.0";
|
||||||
|
options.table = "3";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
vlans = {
|
vlans = {
|
||||||
vlan0 = {
|
"${netifAltVlan}" = {
|
||||||
id = 2;
|
id = 2;
|
||||||
interface = netifLan;
|
interface = netifLan;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
interfaces.vlan0 = {
|
interfaces."${netifAltVlan}" = {
|
||||||
ipv4.addresses = [{
|
ipv4.addresses = [{
|
||||||
address = "103.206.98.200";
|
address = "103.206.98.200";
|
||||||
prefixLength = 29;
|
prefixLength = 29;
|
||||||
|
@ -255,7 +289,7 @@ in
|
||||||
id = "fqdn:igw0.hkg.as150788.net";
|
id = "fqdn:igw0.hkg.as150788.net";
|
||||||
pubkeys = [ "/etc/swanctl/pubkey/igw0.hkg.as150788.net" ];
|
pubkeys = [ "/etc/swanctl/pubkey/igw0.hkg.as150788.net" ];
|
||||||
};
|
};
|
||||||
children.alt0 = {
|
children."${netifAlt}" = {
|
||||||
mode = "transport";
|
mode = "transport";
|
||||||
ah_proposals = [ "sha256-curve25519" ];
|
ah_proposals = [ "sha256-curve25519" ];
|
||||||
remote_ts = [ "103.206.98.1[gre]" ];
|
remote_ts = [ "103.206.98.1[gre]" ];
|
||||||
|
@ -263,6 +297,32 @@ in
|
||||||
start_action = "start";
|
start_action = "start";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
# prevent race condition similar to https://github.com/NixOS/nixpkgs/issues/27070
|
||||||
|
systemd.services.strongswan-swanctl = {
|
||||||
|
after = [ "network-addresses-${netifAlt}.service" ];
|
||||||
|
requires = [ "network-addresses-${netifAlt}.service" ];
|
||||||
|
};
|
||||||
|
services.strongswan-swanctl.swanctl.connections.intl = {
|
||||||
|
local_addrs = [ "94.190.212.123" ];
|
||||||
|
remote_addrs = [ "5.78.16.0" ];
|
||||||
|
local.main = {
|
||||||
|
auth = "pubkey";
|
||||||
|
id = "fqdn:m-labs.hk";
|
||||||
|
pubkeys = [ "/etc/swanctl/pubkey/m-labs.hk" ];
|
||||||
|
};
|
||||||
|
remote.main = {
|
||||||
|
auth = "pubkey";
|
||||||
|
id = "fqdn:m-labs-intl.com";
|
||||||
|
pubkeys = [ "/etc/swanctl/pubkey/m-labs-intl.com" ];
|
||||||
|
};
|
||||||
|
children.intl0 = {
|
||||||
|
mode = "transport";
|
||||||
|
ah_proposals = [ "sha256-curve25519" ];
|
||||||
|
remote_ts = [ "5.78.16.0[gre]" ];
|
||||||
|
local_ts = [ "94.190.212.123[gre]" ];
|
||||||
|
start_action = "start";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
systemd.services.network-custom-route-backup = {
|
systemd.services.network-custom-route-backup = {
|
||||||
wantedBy = [ "network.target" ];
|
wantedBy = [ "network.target" ];
|
||||||
|
@ -282,6 +342,15 @@ in
|
||||||
ExecStop = "${pkgs.iproute2}/bin/ip rule del table 1";
|
ExecStop = "${pkgs.iproute2}/bin/ip rule del table 1";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
systemd.services.network-custom-route-intl = {
|
||||||
|
wantedBy = [ "network.target" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
ExecStart = "${pkgs.iproute2}/bin/ip rule add from 5.78.16.0/32 table 3";
|
||||||
|
ExecStop = "${pkgs.iproute2}/bin/ip rule del table 3";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# https://kb.isc.org/docs/dnssec-key-and-signing-policy
|
# https://kb.isc.org/docs/dnssec-key-and-signing-policy
|
||||||
# chown named.named /etc/nixos/named
|
# chown named.named /etc/nixos/named
|
||||||
|
@ -834,7 +903,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
services.postgresql = {
|
services.postgresql = {
|
||||||
package = pkgs.postgresql_12;
|
package = pkgs.postgresql_15;
|
||||||
settings.listen_addresses = pkgs.lib.mkForce "";
|
settings.listen_addresses = pkgs.lib.mkForce "";
|
||||||
identMap =
|
identMap =
|
||||||
''
|
''
|
||||||
|
@ -1052,15 +1121,6 @@ in
|
||||||
"forum.m-labs.hk" = {
|
"forum.m-labs.hk" = {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
root = "/var/www/flarum/public";
|
|
||||||
locations."~ \.php$".extraConfig = ''
|
|
||||||
fastcgi_pass unix:${config.services.phpfpm.pools.flarum.socket};
|
|
||||||
fastcgi_index index.php;
|
|
||||||
'';
|
|
||||||
extraConfig = ''
|
|
||||||
index index.php;
|
|
||||||
include /var/www/flarum/.nginx.conf;
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
"perso.m-labs.hk" = {
|
"perso.m-labs.hk" = {
|
||||||
addSSL = true;
|
addSSL = true;
|
||||||
|
@ -1132,23 +1192,17 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.mysql = {
|
services.mysql = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.mariadb;
|
package = pkgs.lib.mkForce pkgs.mariadb;
|
||||||
};
|
ensureDatabases = pkgs.lib.mkForce [];
|
||||||
services.phpfpm.pools.flarum = {
|
ensureUsers = pkgs.lib.mkForce [];
|
||||||
user = "nobody";
|
|
||||||
settings = {
|
|
||||||
"listen.owner" = "nginx";
|
|
||||||
"listen.group" = "nginx";
|
|
||||||
"listen.mode" = "0600";
|
|
||||||
"pm" = "dynamic";
|
|
||||||
"pm.max_children" = 5;
|
|
||||||
"pm.start_servers" = 2;
|
|
||||||
"pm.min_spare_servers" = 1;
|
|
||||||
"pm.max_spare_servers" = 3;
|
|
||||||
"pm.max_requests" = 500;
|
|
||||||
};
|
};
|
||||||
|
services.flarum = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.callPackage ./flarum {};
|
||||||
|
domain = "forum.m-labs.hk";
|
||||||
};
|
};
|
||||||
|
|
||||||
services.rt = {
|
services.rt = {
|
||||||
|
@ -1177,6 +1231,18 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment.etc."postfix/sender_relay".text = ''
|
||||||
|
m-labs-intl.com smtptun:
|
||||||
|
* :
|
||||||
|
'';
|
||||||
|
systemd.services.postfix-rebuild-sender-relay = {
|
||||||
|
description = "Postfix Rebuild Sender Dependent Relayhost Maps";
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = "${pkgs.postfix}/sbin/postmap /etc/postfix/sender_relay";
|
||||||
|
};
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
mailserver = {
|
mailserver = {
|
||||||
enable = true;
|
enable = true;
|
||||||
localDnsResolver = false; # conflicts with dnsmasq
|
localDnsResolver = false; # conflicts with dnsmasq
|
||||||
|
@ -1185,8 +1251,17 @@ in
|
||||||
enablePop3 = true;
|
enablePop3 = true;
|
||||||
enablePop3Ssl = true;
|
enablePop3Ssl = true;
|
||||||
certificateScheme = "acme-nginx";
|
certificateScheme = "acme-nginx";
|
||||||
policydSPFExtraConfig = "skip_addresses = 5.78.86.156,2a01:4ff:1f0:83de::1";
|
|
||||||
} // (import /etc/nixos/secret/email_settings.nix);
|
} // (import /etc/nixos/secret/email_settings.nix);
|
||||||
|
services.postfix = {
|
||||||
|
config = {
|
||||||
|
sender_dependent_relayhost_maps = "hash:/etc/postfix/sender_relay";
|
||||||
|
masterConfig.smtptun = {
|
||||||
|
type = "smtp";
|
||||||
|
command = "smtp";
|
||||||
|
args = "-o smtp_bind_address=5.78.16.0";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
services.roundcube = {
|
services.roundcube = {
|
||||||
enable = true;
|
enable = true;
|
||||||
hostName = "mail.m-labs.hk";
|
hostName = "mail.m-labs.hk";
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
php,
|
||||||
|
fetchFromGitHub,
|
||||||
|
fetchpatch,
|
||||||
|
}:
|
||||||
|
|
||||||
|
php.buildComposerProject (finalAttrs: {
|
||||||
|
pname = "flarum";
|
||||||
|
version = "1.8.1";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "flarum";
|
||||||
|
repo = "flarum";
|
||||||
|
rev = "v${finalAttrs.version}";
|
||||||
|
hash = "sha256-kigUZpiHTM24XSz33VQYdeulG1YI5s/M02V7xue72VM=";
|
||||||
|
};
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
# Add useful extensions from https://github.com/FriendsOfFlarum
|
||||||
|
# Extensions included: fof/upload, fof/polls, fof/subscribed
|
||||||
|
./fof-extensions.patch
|
||||||
|
];
|
||||||
|
|
||||||
|
composerLock = ./composer.lock;
|
||||||
|
composerStrictValidation = false;
|
||||||
|
vendorHash = "sha256-z3KVGmILw8MZ4aaSf6IP/0l16LI/Y2yMzY2KMHf4qSg=";
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
changelog = "https://github.com/flarum/framework/blob/main/CHANGELOG.md";
|
||||||
|
description = "Flarum is a delightfully simple discussion platform for your website";
|
||||||
|
homepage = "https://github.com/flarum/flarum";
|
||||||
|
license = lib.licenses.mit;
|
||||||
|
maintainers = with maintainers; [
|
||||||
|
fsagbuya
|
||||||
|
jasonodoom
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
|
@ -0,0 +1,16 @@
|
||||||
|
diff --git a/composer.json b/composer.json
|
||||||
|
index c63b5f8..5ad1186 100644
|
||||||
|
--- a/composer.json
|
||||||
|
+++ b/composer.json
|
||||||
|
@@ -37,7 +37,10 @@
|
||||||
|
"flarum/sticky": "*",
|
||||||
|
"flarum/subscriptions": "*",
|
||||||
|
"flarum/suspend": "*",
|
||||||
|
- "flarum/tags": "*"
|
||||||
|
+ "flarum/tags": "*",
|
||||||
|
+ "fof/polls": "*",
|
||||||
|
+ "fof/subscribed": "*",
|
||||||
|
+ "fof/upload": "*"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"preferred-install": "dist",
|
|
@ -22,8 +22,7 @@ $TTL 7200
|
||||||
ns A 94.190.212.123
|
ns A 94.190.212.123
|
||||||
ns AAAA 2001:470:18:390::2
|
ns AAAA 2001:470:18:390::2
|
||||||
|
|
||||||
mail A 5.78.86.156
|
mail A 5.78.16.0
|
||||||
mail AAAA 2a01:4ff:1f0:83de::1
|
|
||||||
mail._domainkey IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJVPuhSGXghO7ib8Em/Se3jfCCIJK5g4zn5pGZ3/e0I0f+zGHMuvwpjkAKf6eSmo/AAXEaco28pDi3qE5xfV512AJsORCfPoPFyNhLsj/qtri6hc5KVSWW0Ja3MSFBINDCaX78c7PXPY+3jJJGpwSBDLjdxj9AQwtfiCVlH4qE/QIDAQAB"
|
mail._domainkey IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJVPuhSGXghO7ib8Em/Se3jfCCIJK5g4zn5pGZ3/e0I0f+zGHMuvwpjkAKf6eSmo/AAXEaco28pDi3qE5xfV512AJsORCfPoPFyNhLsj/qtri6hc5KVSWW0Ja3MSFBINDCaX78c7PXPY+3jJJGpwSBDLjdxj9AQwtfiCVlH4qE/QIDAQAB"
|
||||||
_dmarc TXT "v=DMARC1; p=none"
|
_dmarc TXT "v=DMARC1; p=none"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue