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?
Is it possible to setup a VPN on Heroku?
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
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.
© 2022 - 2024 — McMap. All rights reserved.