Tinyproxy + faaso-daemon docker image using multirun
This commit is contained in:
parent
0f297e9714
commit
3d529019e6
32
src/daemon.cr
Normal file
32
src/daemon.cr
Normal file
@ -0,0 +1,32 @@
|
||||
require "docr"
|
||||
require "kemal"
|
||||
|
||||
get "/" do
|
||||
"Updating routing"
|
||||
# Get all the funkos, create routes for them all
|
||||
docker_api = Docr::API.new(Docr::Client.new)
|
||||
containers = docker_api.containers.list(all: true)
|
||||
|
||||
funkos = [] of String
|
||||
containers.each { |container|
|
||||
names = container.names.select &.starts_with? "/faaso-"
|
||||
next if names.empty?
|
||||
funkos << names[0][7..]
|
||||
}
|
||||
|
||||
proxy_config = %(
|
||||
Port 8888
|
||||
Listen 0.0.0.0
|
||||
Timeout 600
|
||||
Allow 0.0.0.0/0
|
||||
ReverseOnly Yes
|
||||
ReverseMagic Yes
|
||||
ReversePath "/admin/" "http://127.0.0.1:3000/"
|
||||
) + funkos.map { |funko| %(ReversePath "/faaso/#{funko}/" "http://#{funko}:3000/") }.join("\n")
|
||||
|
||||
File.open("/etc/tinyproxy/tinyproxy.conf", "w") do |file|
|
||||
file << proxy_config
|
||||
end
|
||||
end
|
||||
|
||||
Kemal.run
|
@ -1,7 +0,0 @@
|
||||
Port 8888
|
||||
Listen 0.0.0.0
|
||||
Timeout 600
|
||||
Allow 0.0.0.0/0
|
||||
ReverseOnly Yes
|
||||
ReversePath "/faaso/hello/" "http://hello:3000/"
|
||||
ReverseMagic Yes
|
Loading…
Reference in New Issue
Block a user