mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
chore(access): bring back octoprint
This commit is contained in:
parent
1bbe964f6a
commit
9f5ebdba42
1 changed files with 60 additions and 0 deletions
60
nixos/access/octoprint.nix
Normal file
60
nixos/access/octoprint.nix
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.modules) mkIf mkDefault;
|
||||||
|
inherit (config.services) octoprint;
|
||||||
|
name.shortServer = mkDefault "print";
|
||||||
|
upstreamName = "octoprint'access";
|
||||||
|
in {
|
||||||
|
config.services.nginx = {
|
||||||
|
upstreams'.${upstreamName}.servers = {
|
||||||
|
local = {
|
||||||
|
enable = mkDefault octoprint.enable;
|
||||||
|
addr = mkDefault "localhost";
|
||||||
|
port = mkIf octoprint.enable (mkDefault octoprint.port);
|
||||||
|
};
|
||||||
|
service = {upstream, ...}: {
|
||||||
|
enable = mkIf upstream.servers.local.enable (mkDefault false);
|
||||||
|
accessService = {
|
||||||
|
name = "octoprint";
|
||||||
|
# XXX: logistics doesn't listen on v6
|
||||||
|
getAddressFor = "getAddress4For";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
virtualHosts = let
|
||||||
|
copyFromVhost = mkDefault "octoprint";
|
||||||
|
locations = {
|
||||||
|
"/" = {
|
||||||
|
proxy.enable = true;
|
||||||
|
};
|
||||||
|
"/sockjs/" = {
|
||||||
|
proxy = {
|
||||||
|
enable = true;
|
||||||
|
websocket.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
# TODO: unprotect timelapse download links via vouch? may also need guest permissions...
|
||||||
|
# TODO: make a view alternate location prefix that changes content-type?
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
octoprint = {
|
||||||
|
inherit name locations;
|
||||||
|
proxy.upstream = mkDefault upstreamName;
|
||||||
|
vouch.enable = mkDefault true;
|
||||||
|
};
|
||||||
|
octoprint'local = {
|
||||||
|
inherit name locations;
|
||||||
|
ssl.cert = {
|
||||||
|
inherit copyFromVhost;
|
||||||
|
};
|
||||||
|
proxy = {
|
||||||
|
inherit copyFromVhost;
|
||||||
|
};
|
||||||
|
local.enable = mkDefault true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue