Fixed terminal proxying/auth

This commit is contained in:
Roberto Alsina 2024-07-07 16:06:49 -03:00
parent 10775aeb11
commit 2ddbda5a4f
4 changed files with 6 additions and 34 deletions

View File

@ -6,7 +6,7 @@
* Config UI in frontend? * Config UI in frontend?
* Polish frontend UI **A LOT** * Polish frontend UI **A LOT**
* ✅ Version checks for consistency between client/server * ✅ Version checks for consistency between client/server
* Have 3 runtimes: * Have 3 runtimes:
* ✅ Crystal + Kemal * ✅ Crystal + Kemal
* ✅ Python + Flask * ✅ Python + Flask
* ✅ Nodejs + Express * ✅ Nodejs + Express

View File

@ -18,11 +18,5 @@ http://*:8888 {
handle_path /admin/* { handle_path /admin/* {
reverse_proxy /* http://127.0.0.1:3000 reverse_proxy /* http://127.0.0.1:3000
} }
handle_path /faaso/exp/* { import funkos
reverse_proxy /* http://faaso-exp-6ne49v:3000 { }
health_uri /ping
fail_duration 30s
}
}
}

View File

@ -4,7 +4,7 @@ require "inotify"
require "kemal" require "kemal"
module Proxy module Proxy
CADDY_CONFIG_PATH = "config/Caddyfile" CADDY_CONFIG_PATH = "config/funkos"
@@current_config = File.read(CADDY_CONFIG_PATH) @@current_config = File.read(CADDY_CONFIG_PATH)
@@watcher = Inotify.watch(CADDY_CONFIG_PATH) do |_| @@watcher = Inotify.watch(CADDY_CONFIG_PATH) do |_|
@ -28,29 +28,8 @@ module Proxy
def self.update_proxy_config def self.update_proxy_config
docker_api = Docr::API.new(Docr::Client.new) docker_api = Docr::API.new(Docr::Client.new)
containers = docker_api.containers.list(all: true) containers = docker_api.containers.list(all: true)
config = <<-CONFIG
{
http_port 8888
https_port 8887
local_certs
}
http://*:8888 {
forward_auth /admin/* http://127.0.0.1:3000 {
uri /auth
copy_headers {
Authorization
}
}
handle_path /admin/terminal/* {
reverse_proxy /* http://127.0.0.1:7681
}
handle_path /admin/* {
reverse_proxy /* http://127.0.0.1:3000
}
CONFIG
config = ""
funkos = Funko::Funko.from_docker funkos = Funko::Funko.from_docker
funkos.each do |funko| funkos.each do |funko|
next if funko.name == "proxy" next if funko.name == "proxy"
@ -68,7 +47,6 @@ CONFIG
} }
) )
end end
config += "\n}"
if @@current_config != config if @@current_config != config
Log.info { "Updating proxy config" } Log.info { "Updating proxy config" }

View File

@ -4,7 +4,7 @@ module Terminal
@@terminal_process : Process | Nil = nil @@terminal_process : Process | Nil = nil
def start_terminal(_args = ["sh"], readonly = true) def start_terminal(_args = ["sh"], readonly = true)
args = ["-p", "7681", "-c", "admin:admin", "-o"] args = ["-p", "7681", "-o"]
args += ["-W"] unless readonly args += ["-W"] unless readonly
args += _args args += _args
# We have a process there, kill it # We have a process there, kill it