ma ham: proxy pass via nginx

This commit is contained in:
makefu 2021-03-08 23:41:47 +01:00
parent d0fc18d228
commit 914163cec3
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
2 changed files with 69 additions and 20 deletions

View File

@ -7,10 +7,20 @@ let
prefix = (import ./lib).prefix; prefix = (import ./lib).prefix;
firetv_stick = "192.168.1.24"; firetv_stick = "192.168.1.24";
hassdir = "/var/lib/hass"; hassdir = "/var/lib/hass";
unstable = import (pkgs.fetchFromGitHub {
owner = "nixos";
repo = "nixpkgs";
rev = (lib.importJSON ../../../krebs/nixpkgs-unstable.json).rev;
sha256 = (lib.importJSON ../../../krebs/nixpkgs-unstable.json).sha256;
}) {};
in { in {
imports = [ imports = [
./nginx.nix
./mqtt.nix ./mqtt.nix
./zigbee2mqtt/default.nix ./zigbee2mqtt
./signal-rest
# hass config # hass config
./zigbee2mqtt/hass.nix ./zigbee2mqtt/hass.nix
@ -25,11 +35,13 @@ in {
./calendar/nextcloud.nix ./calendar/nextcloud.nix
./automation/fenster_auf.nix
./automation/firetv_restart.nix ./automation/firetv_restart.nix
./automation/light_buttons.nix ./automation/light_buttons.nix
./automation/wohnzimmer_rf_fernbedienung.nix ./automation/wohnzimmer_rf_fernbedienung.nix
./automation/giesskanne.nix ./automation/giesskanne.nix
./automation/urlaub.nix #./automation/urlaub.nix
./automation/moodlight.nix
./light/arbeitszimmer.nix ./light/arbeitszimmer.nix
./light/schlafzimmer.nix ./light/schlafzimmer.nix
@ -37,6 +49,15 @@ in {
]; ];
services.home-assistant = { services.home-assistant = {
package = (unstable.home-assistant.overrideAttrs (old: {
doInstallCheck = false;
})).override {
extraPackages = p: [
(p.callPackage ./deps/dwdwfsapi.nix {})
(p.callPackage ./deps/pykodi.nix {})
p.APScheduler ];
};
config = { config = {
influxdb = { influxdb = {
database = "ham"; database = "ham";
@ -53,6 +74,13 @@ in {
latitude = "48.7687"; latitude = "48.7687";
longitude = "9.2478"; longitude = "9.2478";
elevation = 247; elevation = 247;
auth_providers = [
{ type = "trusted_networks";
trusted_networks = [ "192.168.1.0/24" ];
allow_bypass_login = true;
}
{ type = "homeassistant"; }
];
}; };
discovery = {}; discovery = {};
conversation = {}; conversation = {};
@ -72,33 +100,39 @@ in {
api = {}; api = {};
esphome = {}; esphome = {};
camera = []; camera = [];
telegram_bot = [ #telegram_bot = [
# secrets file: { # # secrets file: {
# "platform": "broadcast", # # "platform": "broadcast",
# "api_key": "", # talk to Botfather /newbot # # "api_key": "", # talk to Botfather /newbot
# "allowed_chat_ids": [ ID ] # curl -X GET # https://api.telegram.org/bot<YOUR_API_TOKEN>/getUpdates # # "allowed_chat_ids": [ ID ] # curl -X GET # https://api.telegram.org/bot<YOUR_API_TOKEN>/getUpdates
# } # # }
(builtins.fromJSON # (builtins.fromJSON
(builtins.readFile <secrets/hass/telegram-bot.json>)) # (builtins.readFile <secrets/hass/telegram-bot.json>))
]; #];
notify = [ notify = [
{ {
platform = "kodi"; platform = "kodi";
name = "wohnzimmer"; name = "Kodi Wohnzimmer";
host = firetv_stick; host = firetv_stick;
} }
{ {
platform = "telegram"; platform = "nfandroidtv";
name = "telegrambot"; name = "FireTV Wohnzimmer";
chat_id = builtins.elemAt host = firetv_stick;
(builtins.fromJSON (builtins.readFile }
<secrets/hass/telegram-bot.json>)).allowed_chat_ids 0; #{
} # platform = "telegram";
# name = "telegrambot";
# chat_id = builtins.elemAt
# (builtins.fromJSON (builtins.readFile
# <secrets/hass/telegram-bot.json>)).allowed_chat_ids 0;
#}
]; ];
sun.elevation = 247; sun.elevation = 247;
recorder = {}; recorder = {};
media_player = [ media_player = [
{ platform = "FireTV Stick kodi"; { platform = "kodi";
name = "FireTV Stick kodi";
host = firetv_stick; host = firetv_stick;
} }
{ platform = "androidtv"; { platform = "androidtv";
@ -146,7 +180,12 @@ in {
# https://www.home-assistant.io/cookbook/automation_for_rainy_days/ # https://www.home-assistant.io/cookbook/automation_for_rainy_days/
]; ];
frontend = { }; frontend = { };
http = { }; http = {
use_x_forwarded_for = true;
server_host = "127.0.0.1";
trusted_proxies = [ "127.0.0.1" ];
#trusted_proxies = [ "192.168.1.0/24" ];
};
switch = []; switch = [];
automation = []; automation = [];
script = { }; script = { };

View File

@ -0,0 +1,10 @@
let
internal-ip = "192.168.1.11";
in {
services.nginx.recommendedProxySettings = true;
services.nginx.virtualHosts."hass" = {
serverAliases = [ "hass.lan" "ha" "ha.lan" ];
locations."/".proxyPass = "http://localhost:8123";
locations."/".proxyWebsockets = true;
};
}