Class: AcmeManager::Middleware::ForwardVerificationChallenge

Inherits:
Object
  • Object
show all
Defined in:
lib/acme_manager/middleware/forward_verification_challenge.rb

Overview

If your setup is such that you cannot use a load-balancer to automatically syphon off LE requests to /.well-known/acme-challenge and direct them to acme-manager, you can use this middleware instead to act as a proxy between LE and acme-manager

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ForwardVerificationChallenge

Returns a new instance of ForwardVerificationChallenge.



7
8
9
# File 'lib/acme_manager/middleware/forward_verification_challenge.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/acme_manager/middleware/forward_verification_challenge.rb', line 11

def call(env)
  if env['PATH_INFO'] =~ %r{\A/.well-known/acme-challenge/}
    AcmeManager.logger.info "Fowarding request to #{env['PATH_INFO']} to #{AcmeManager.config.host}"
    result = Net::HTTP.get_response(URI("#{AcmeManager.config.host}#{env['PATH_INFO']}"))
    [result.code.to_i, result.to_hash, [result.body]]
  else
    @app.call(env)
  end
end