Skip to content

Commit

Permalink
Use server host name instead of ip
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoriguchi committed Sep 18, 2024
1 parent 90170c7 commit e2b3e9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions configuration/devices/headless/router/adguardhome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ let

wingoRouterIp = "192.168.0.254";
routerIp = "192.168.1.1";
serverIp = "192.168.2.2";

dnsmasqPort = config.services.dnsmasq.settings.port;
in {
Expand Down Expand Up @@ -112,16 +111,17 @@ in {
domain = "winbox.local";
answer = wingoRouterIp;
}
# this entry needs to exist else this domain can't be resolved
{
domain = "${config.networking.hostName}.local";
answer = routerIp;
}
] ++ (map (domain: {
inherit domain;
answer = routerIp;
answer = "${config.networking.hostName}.local";
}) config.services.infomaniak.hostnames) ++ (map (domain: {
inherit domain;
answer = serverIp;
answer = "XXLPitu-Server.local";
}) [
"deluge.00a.ch"
"esphome.00a.ch"
Expand Down
10 changes: 5 additions & 5 deletions configuration/devices/headless/router/web-proxy.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{ config, lib, ... }:
let serverIp = "192.168.2.2";
in {
{ config, lib, ... }: {
services.nginx = {
enable = true;

Expand All @@ -10,12 +8,14 @@ in {
domains = lib.attrNames config.services.nginx.virtualHosts;
localRoutings = map (domain: "${domain} ${config.networking.hostName};") (lib.filter (domain: domain != "*.00a.ch") domains);
in ''
resolver 127.0.0.1;
upstream ${config.networking.hostName} {
server 127.0.0.1:${toString config.services.nginx.defaultSSLListenPort};
}
upstream XXLPitu-Server {
server ${serverIp}:443;
server XXLPitu-Server.local:443;
}
map $ssl_preread_server_name $upstream {
Expand All @@ -39,7 +39,7 @@ in {
port = config.services.nginx.defaultHTTPListenPort;
}) config.services.nginx.defaultListenAddresses;

locations."/".proxyPass = "http://${serverIp}:80";
locations."/".proxyPass = "http://XXLPitu-Server.local:80";
};
};
}

0 comments on commit e2b3e9d

Please sign in to comment.