37 lines
628 B
Ruby
37 lines
628 B
Ruby
|
require 'erb'
|
||
|
|
||
|
|
||
|
class NGINXProxy
|
||
|
class << self
|
||
|
attr_accessor :domain, :port, :service
|
||
|
|
||
|
def domain(value = nil)
|
||
|
@domain = value unless value.nil?
|
||
|
@domain
|
||
|
end
|
||
|
|
||
|
def port(value = nil)
|
||
|
@port = value unless value.nil?
|
||
|
@port
|
||
|
end
|
||
|
|
||
|
def service(value = nil)
|
||
|
@service = value unless value.nil?
|
||
|
@service
|
||
|
end
|
||
|
|
||
|
def generate
|
||
|
template = File.read("proxy.erb")
|
||
|
template = ERB.new(template)
|
||
|
template.result(binding)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
class ExampleProxy < NGINXProxy
|
||
|
domain "gurgul.org"
|
||
|
service "forgejo"
|
||
|
port 3000
|
||
|
end
|
||
|
|
||
|
puts ExampleProxy.generate
|