Is it possible to setup a VPN on Heroku?
Asked Answered
P

2

11

Is it possible to setup a VPN using openVPN on heroku to keep a staging environment private? If so, anyone have a writeup or links?

Papyraceous answered 13/11, 2009 at 1:2 Comment(0)
P
4

You can't do this with a VPN, but you could password protect a staging instance of your site. In order to do this you'd want to set up a new Rails environment called "staging" and include something like the following in your ApplicationController:

class ApplicationController

  before_filter :password_protected if Rails.env.staging?

  protected

  def password_protected
    authenticate_or_request_with_http_basic do |username, password|
      username == "foo" && password == "bar"
    end
  end

end

You would then need to make sure your staging instance's environment:

heroku config:add RACK_ENV=staging
Phelgon answered 16/11, 2009 at 1:22 Comment(0)
T
0

Securing staging environment on heroku with firewall and vpn isn't possible. A cleaner solution with rails 3 (easily applicable to sinatra too), similiar to that of David is

# config/environments/staging.rb

MyApp::Application.configure do
  config.middleware.insert_after(::Rack::Lock, "::Rack::Auth::Basic", "Staging") do |u, p|
    [u, p] == ['username', 'password']
  end

 #... other config
end

I wrote a short blog post about it.

Taneshatang answered 6/4, 2011 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.