feat(rpi4): expose mosquitto via nginx
This commit is contained in:
parent
18f7f733c3
commit
79f03b3318
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
with pkgs;
|
with pkgs;
|
||||||
|
|
||||||
|
let
|
||||||
|
mqttDomain = "mqtt.${config.networking.domain}";
|
||||||
|
in
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [ deconz ];
|
environment.systemPackages = with pkgs; [ deconz ];
|
||||||
|
|
||||||
|
@ -12,22 +15,30 @@ with pkgs;
|
||||||
openFirewall = true;
|
openFirewall = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users.mosquitto.extraGroups = [ "acme" ];
|
services.nginx = {
|
||||||
|
virtualHosts = {
|
||||||
|
${ mqttDomain } = {
|
||||||
|
enableACME = true;
|
||||||
|
forceSSL = true;
|
||||||
|
locations."/" = {
|
||||||
|
proxyPass = "http://localhost:${toString config.services.mosquitto.port}";
|
||||||
|
proxyWebsockets = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [
|
networking.firewall.allowedTCPPorts = [
|
||||||
config.services.mosquitto.ssl.port
|
config.services.mosquitto.port
|
||||||
];
|
];
|
||||||
|
|
||||||
services.mosquitto = {
|
services.mosquitto = {
|
||||||
enable = true;
|
enable = true;
|
||||||
host = "0.0.0.0";
|
host = "0.0.0.0";
|
||||||
checkPasswords = true;
|
checkPasswords = true;
|
||||||
ssl = {
|
extraConf = ''
|
||||||
enable = true;
|
protocol websockets
|
||||||
cafile = "/var/lib/acme/${config.networking.domain}/chain.pem";
|
'';
|
||||||
certfile = "/var/lib/acme/${config.networking.domain}/cert.pem";
|
|
||||||
keyfile = "/var/lib/acme/${config.networking.domain}/key.pem";
|
|
||||||
};
|
|
||||||
users = {
|
users = {
|
||||||
"hass" = {
|
"hass" = {
|
||||||
acl = [
|
acl = [
|
||||||
|
@ -37,6 +48,12 @@ with pkgs;
|
||||||
];
|
];
|
||||||
hashedPasswordFile = "/etc/nixos/secrets/mqtt/hass";
|
hashedPasswordFile = "/etc/nixos/secrets/mqtt/hass";
|
||||||
};
|
};
|
||||||
|
#"tasmota" = {
|
||||||
|
# acl = [
|
||||||
|
# "topic readwrite tasmota/#"
|
||||||
|
# ];
|
||||||
|
# hashedPasswordFile = "/etc/nixos/secrets/mqtt/tasmota";
|
||||||
|
#};
|
||||||
"owntracks" = {
|
"owntracks" = {
|
||||||
acl = [
|
acl = [
|
||||||
"topic readwrite owntracks/#"
|
"topic readwrite owntracks/#"
|
||||||
|
@ -49,7 +66,9 @@ with pkgs;
|
||||||
services.home-assistant = {
|
services.home-assistant = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = home-assistant.override {
|
package = home-assistant.override {
|
||||||
extraPackages = ps: with ps; [ (callPackage pydeconz { }) ];
|
extraPackages = ps: with ps; [
|
||||||
|
(callPackage pydeconz { })
|
||||||
|
];
|
||||||
};
|
};
|
||||||
openFirewall = true;
|
openFirewall = true;
|
||||||
config = {
|
config = {
|
||||||
|
|
Loading…
Reference in a new issue