Switched to caddy because tinyproxy is too limited
This commit is contained in:
@ -2,7 +2,7 @@ require "docr"
|
||||
require "kemal"
|
||||
|
||||
module Proxy
|
||||
@@current_config = File.read("tinyproxy.conf")
|
||||
@@current_config = File.read("Caddyfile")
|
||||
|
||||
# Get current proxy config
|
||||
get "/proxy/" do
|
||||
@ -30,24 +30,31 @@ module Proxy
|
||||
funkos.sort!
|
||||
|
||||
config = %(
|
||||
User nobody
|
||||
Group nogroup
|
||||
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/"
|
||||
ReversePath "/admin/terminal/" "http://127.0.0.1:7681"
|
||||
) + funkos.map { |funko| %(ReversePath "/faaso/#{funko.split("-")[0]}/" "http://#{funko}:3000/") }.join("\n")
|
||||
{
|
||||
https_port 8888
|
||||
http_port 8887
|
||||
local_certs
|
||||
}
|
||||
|
||||
localhost:8888 {
|
||||
handle_path /admin/terminal/* {
|
||||
reverse_proxy /* http://127.0.0.1:7681
|
||||
}
|
||||
handle_path /admin/* {
|
||||
reverse_proxy /* http://127.0.0.1:3000
|
||||
}
|
||||
) + funkos.map { |funko| %(
|
||||
handle_path /faaso/#{funko.split("-")[0]}/* {
|
||||
reverse_proxy /* http://#{funko}:3000
|
||||
}
|
||||
)}.join("\n") +"}"
|
||||
|
||||
if @@current_config != config
|
||||
File.open("tinyproxy.conf", "w") do |file|
|
||||
File.open("Caddyfile", "w") do |file|
|
||||
file << config
|
||||
end
|
||||
# Reload config
|
||||
Process.run(command: "/usr/bin/killall", args: ["-USR1", "tinyproxy"])
|
||||
Process.run(command: "/usr/bin/killall", args: ["-USR1", "caddy"])
|
||||
@@current_config = config
|
||||
end
|
||||
config
|
||||
|
@ -3,7 +3,7 @@ module Terminal
|
||||
|
||||
@@terminal_process : Process | Nil = nil
|
||||
|
||||
def start_terminal(_args = ["bash"], readonly = false)
|
||||
def start_terminal(_args = ["sh"], readonly = false)
|
||||
args = ["-p", "7681", "-c", "admin:admin", "-o"]
|
||||
args += ["-W"] unless readonly
|
||||
args += _args
|
||||
@ -16,5 +16,3 @@ module Terminal
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Terminal.start_terminal
|
Reference in New Issue
Block a user