Class: ASF::HTTPS_workarounds

Inherits:
Object
  • Object
show all
Defined in:
lib/whimsy/asf/rack.rb

Overview

Apache httpd on whimsy-vm is behind a proxy that converts https requests into http requests. Update the environment variables to match.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ HTTPS_workarounds

Returns a new instance of HTTPS_workarounds.



176
177
178
# File 'lib/whimsy/asf/rack.rb', line 176

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/whimsy/asf/rack.rb', line 180

def call(env)
  if env['HTTPS'] == 'on'
    env['SCRIPT_URI'].sub!(/^http:/, 'https:')
    env['SERVER_PORT'] = '443'

    # for reasons I don't understand, Passenger on whimsy doesn't
    # forward root directory requests directly, so as a workaround
    # these requests are rewritten and the following code maps
    # the requests back:
    if env['PATH_INFO'] == '/index.html'
      env['PATH_INFO'] = '/'
      env['SCRIPT_URI'] += '/'
    end
  end

  return  @app.call(env)
end