Configure Nginx virtual host for audiobookshelf

This commit is contained in:
Oliver Davies 2025-04-28 00:53:26 +01:00
parent 8baa3ea1cb
commit e1c30789a2
3 changed files with 27 additions and 2 deletions

View file

@ -14,6 +14,7 @@
extraDomainNames = [
"2020.oliverdavies.uk"
"audiobookshelf.oliverdavies.uk"
"bootstrap-with-tailwind.oliverdavies.uk"
"code.oliverdavies.uk"
"eric.oliverdavies.uk"

View file

@ -1,5 +1,8 @@
{ config, ... }:
let
cfg = config.services.audiobookshelf;
in
{
services = {
audiobookshelf = {
@ -8,10 +11,22 @@
port = 4001;
};
caddy.virtualHosts."audiobookshelf.oliverdavies.uk" = {
nginx.virtualHosts."audiobookshelf.oliverdavies.uk" = {
forceSSL = true;
useACMEHost = "oliverdavies.uk";
extraConfig = "reverse_proxy localhost:${toString config.services.audiobookshelf.port}";
locations."/" = {
proxyPass = "http://localhost:${toString cfg.port}";
extraConfig = ''
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Real-IP $remote_addr;
'';
};
};
};
}

View file

@ -11,6 +11,15 @@
siteMonitor = "http://localhost:8096";
};
}
{
"Audiobookshelf" = {
href = "https://audiobookshelf.oliverdavies.uk";
icon = "audiobookshelf";
description = "Self-hosted audiobook and podcast server";
siteMonitor = "http://localhost:4001";
};
}
];
}