在Heroku上设置VPN是否可行?

11

是否可以在Heroku上使用openVPN设置VPN以保持暂存环境的私密性?如果可以,有没有任何文档或链接?

2个回答

4

使用VPN无法实现此操作,但您可以为您的网站设置一个暂存实例并加密密码。为此,您需要设置一个名为“staging”的新的Rails环境,并在您的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

您需要确保暂存实例的环境:

heroku config:add RACK_ENV=staging

0

使用防火墙和VPN保护Heroku上的暂存环境是不可能的。针对Rails 3的更加清晰的解决方案(也适用于Sinatra),与David类似的解决方案如下:

# 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

我写了一篇关于它的短博客文章


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接