【问题标题】:Capistrano deploy through chain of serversCapistrano 通过服务器链部署
【发布时间】:2011-01-27 22:06:18
【问题描述】:

我需要通过 capistrano 将 Rails 应用程序部署到远程 Intranet 上的服务器。例如,如果我要 ssh 到目标服务器,它看起来像:

localhost$ ssh server1
server1$ ssh server2

最好的方法是什么?

提前致谢。

【问题讨论】:

    标签: ruby-on-rails capistrano


    【解决方案1】:

    Capistrano 让这一切变得非常简单。只需使用

    set :gateway, "user@server1:port"
    

    在您的 config/deploy.rb 中。

    【讨论】:

      【解决方案2】:

      我建议使用:

      set :ssh_options, { :forward_agent => true }
      set :gateway, "user@host:port"
      

      【讨论】:

        【解决方案3】:

        显然,从 v3 开始的 capistrano 中删除了网关选项。相反,可以使用如下所示的跳转代理:https://github.com/capistrano/sshkit#proxying

        这是它在配置文件(例如 production.rb)中的外观:

        require 'net/ssh'
        require 'net/ssh/proxy/jump'
        
        
        set :ssh_options, {
            proxy: Net::SSH::Proxy::Jump.new("user@host:port")
        }
        

        顺便说一句,您可以使用 ssh 命令的 -J 选项指定跳转代理,这样您就可以与 capistrano 分开调试连接问题。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-08-26
          • 1970-01-01
          • 2017-12-27
          • 1970-01-01
          • 1970-01-01
          • 2014-05-26
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多