mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
chore(fluidd): integrate into access
it's just a static file overlay on top of moonraker
This commit is contained in:
parent
41f2fcd403
commit
e4d9ebf56e
6 changed files with 117 additions and 54 deletions
|
|
@ -23,7 +23,7 @@ in {
|
|||
portName = "stream";
|
||||
};
|
||||
mkSubFilter = port: ''
|
||||
sub_filter '${port.protocol}://kitchen.local.gensokyo.zone:${toString port.port}/' '/';
|
||||
sub_filter '${port.protocol}://$host:${toString port.port}/' '/';
|
||||
'';
|
||||
extraConfig = ''
|
||||
proxy_redirect off;
|
||||
|
|
|
|||
110
nixos/access/moonraker.nix
Normal file
110
nixos/access/moonraker.nix
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge mkAfter mkDefault;
|
||||
name.shortServer = mkDefault "print";
|
||||
upstreamName = "moonraker'access";
|
||||
upstreamNameMotion = "moonraker'motion";
|
||||
inherit (config.services) fluidd;
|
||||
cfg = config.services.moonraker;
|
||||
in {
|
||||
config.services.nginx = {
|
||||
upstreams'.${upstreamName} = {
|
||||
servers = {
|
||||
local = {
|
||||
enable = mkDefault cfg.enable;
|
||||
addr = mkDefault "localhost";
|
||||
port = mkIf cfg.enable (mkDefault cfg.port);
|
||||
};
|
||||
service = {upstream, ...}: {
|
||||
enable = mkIf upstream.servers.local.enable (mkDefault false);
|
||||
accessService = {
|
||||
name = "moonraker";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
upstreams'.${upstreamNameMotion} = {
|
||||
servers.service = {
|
||||
accessService = {
|
||||
name = "motion";
|
||||
port = "stream";
|
||||
};
|
||||
};
|
||||
};
|
||||
virtualHosts = let
|
||||
copyFromVhost = mkDefault "moonraker";
|
||||
root = "${fluidd.package}/share/fluidd/htdocs";
|
||||
locations = {
|
||||
"/" = {
|
||||
inherit root;
|
||||
index = "index.html";
|
||||
tryFiles = "$uri $uri/ @moonraker";
|
||||
# XXX: gzip filter failed to use preallocated memory: 350272 of 336176
|
||||
extraConfig = ''
|
||||
gzip off;
|
||||
'';
|
||||
};
|
||||
"/index.html" = {
|
||||
inherit root;
|
||||
headers.set.Cache-Control = "no-store, no-cache, must-revalidate";
|
||||
};
|
||||
"/webcam" = {
|
||||
proxy = {
|
||||
enable = true;
|
||||
upstream = upstreamNameMotion;
|
||||
path = "/2/stream";
|
||||
};
|
||||
extraConfig = ''
|
||||
proxy_buffering off;
|
||||
set $args "";
|
||||
'';
|
||||
};
|
||||
"/websocket" = {
|
||||
proxy = {
|
||||
enable = true;
|
||||
websocket.enable = true;
|
||||
};
|
||||
};
|
||||
# TODO: "~ ^/(printer|api|access|machine|server)/" ?
|
||||
"@moonraker" = {
|
||||
proxy = {
|
||||
enable = true;
|
||||
path = mkDefault "";
|
||||
# TODO: path = mkDefault "$request_uri";
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
moonraker = {
|
||||
inherit name;
|
||||
locations = mkMerge [
|
||||
locations
|
||||
{
|
||||
"/index.html".vouch.requireAuth = true;
|
||||
"/webcam".vouch.requireAuth = true;
|
||||
"/websocket".vouch.requireAuth = true;
|
||||
"@moonraker".vouch.requireAuth = true;
|
||||
}
|
||||
];
|
||||
proxy.upstream = mkDefault upstreamName;
|
||||
vouch = {
|
||||
enable = mkDefault true;
|
||||
requireAuth = false;
|
||||
};
|
||||
};
|
||||
moonraker'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