Web App Staging Server 的最佳实践(预算有限) [英] Best Practices for a Web App Staging Server (on a budget)

查看:46
本文介绍了Web App Staging Server 的最佳实践(预算有限)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为 Rails 应用设置一个临时服务器.我使用 git &github,Cap,并有一个带有 Apache/Passenger 的 VPS.我很好奇暂存设置的最佳实践,就暂存服务器的配置以及与其交互的过程而言.我知道它应该尽可能与生产服务器相同,但限制公众访问它会限制它,因此保护它仅供我使用的提示也很棒.

I'd like to set up a staging server for a Rails app. I use git & github, Cap, and have a VPS with Apache/Passenger. I'm curious as to the best practices for a staging setup, as far as both the configuration of the staging server as well as the processes for interacting with it. I do know it should be as identical to the production server as possible, but restricting public access to it will limit that, so tips on securing it only for my use would also be great.

另一个具体问题是我是否可以在 VPS 上创建一个虚拟主机,以便临时服务器可以与生产服务器一起驻留.不过,我觉得可能有理由避免这种情况.

Another specific question would be whether I could just create a virtual host on the VPS, so that the staging server could reside alongside the production one. I have a feeling there may be reasons to avoid this, though.

推荐答案

便宜又简单的答案:

1) 将 staging.domainname.com 指向您的 VPS.

1) Point staging.domainname.com at your VPS.

2) 添加用于暂存的虚拟主机,指向应用的暂存副本.

2) Add in a virtual host for staging, pointing to the staging copy of the app.

3) 添加暂存环境设置.(你知道你可以定义新的Rails 中的环境?有趣的东西!)我认为这就像将 production.rb 复制到 staging.rb 并根据需要进行调整一样简单,再加上更新 database.yml.

3) Add in a staging environment setting. (Did you know you could define new environments in Rails? Fun stuff!) I think this is as simple as copying production.rb to staging.rb and tweaking as necessary, plus updating database.yml.

4) 在ActionController中,添加类似如下代码

4) In ActionController, add in code similar to the following

   if (ENV["RAILS_ENV"] == "staging")
     before_filter :verifies_admin
   end

其中 verifying_admin 可以是您想要的任何内容.我建议使用 HTTP 基本身份验证——既便宜又简单.

Where verifies_admin can be anything you want. I suggest using HTTP basic authentication -- cheap and easy.

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

请注意,如果他们向您发出入站请求,这可能会中断您与该支付站点的连接,尽管这很容易修复(只需关闭相应控制器的 before_filter 和/或动作.)

Note that this may bork your connection to that payment site if they are making inbound requests to you, although that is simple enough to fix (just turn off the before_filter for the appropriate controllers and/or actions.)

更好的答案:

1) 购买第二个 VPS,使用与常规 VPS 相同的映像配置,和/或使用相同的从裸机安装脚本进行配置(我喜欢 Capistrano 和 Deprec).

1) Buy a second VPS configured from the same image as your regular VPS, and/or configured from the same install-from-the-bare-metal script (I like Capistrano & Deprec for this).

2) 将 staging.domainname.com 指向它.

2) Point staging.domainname.com at it.

3) 否则与其他选项相同.

3) Otherwise its the same as the other option.

需要考虑的事情:

1) 我也应该有一个临时数据库吗?可能,尤其是当您要测试架构更改时.

1) Should I have a staging database as well? Probably, especially if you're going to be testing schema changes.

2) 我是否应该有一些设施来在暂存系统和生产系统之间移动数据?

2) Should I have some facility for moving data between the staging and production systems?

3) 我的暂存应用程序的灾难性故障会导致主应用程序停止运行吗?希望答案是否定的.

3) Can catastrophic failure of my staging application take down the main application? Best hope the answer is no.

这篇关于Web App Staging Server 的最佳实践(预算有限)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆