【问题标题】:Is it possible to setup a VPN on Heroku?是否可以在 Heroku 上设置 VPN?
【发布时间】:2010-12-16 03:18:32
【问题描述】:

是否可以在 heroku 上使用 openVPN 设置 VPN 以保持暂存环境的私密性?如果是这样,有人有文章或链接吗?

【问题讨论】:

    标签: cloud heroku vpn openvpn


    【解决方案1】:

    您无法使用 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
    

    【讨论】:

      【解决方案2】:

      不可能使用防火墙和 vpn 在 heroku 上保护暂存环境。与 David 类似的带有 rails 3 的更清洁的解决方案(也很容易适用于 sinatra)是

      # 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
      

      我为此写了一个简短的blog post

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-07-20
        • 2012-10-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-18
        • 2020-10-04
        相关资源
        最近更新 更多