可以在 Heroku 上设置 VPN 吗?

发布于 2024-08-11 13:04:43 字数 67 浏览 10 评论 0原文

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

舂唻埖巳落 2024-08-18 13:04:43

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

然后您需要确保您的 staging 实例的环境:

heroku config:add RACK_ENV=staging

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
剩一世无双 2024-08-18 13:04:43

使用防火墙和 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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文