【问题标题】:Mounting a rack application in Rails 2.3.12 and HTTPS failing在 Rails 2.3.12 中安装机架应用程序和 HTTPS 失败
【发布时间】:2011-10-25 12:14:47
【问题描述】:

我正在尝试安装一个机架应用程序来加载我的 rails 2.3.12 应用程序,该应用程序在某些控制器中使用 ssl。一切正常,直到我请求任何使用 HTTPS 的页面,然后我得到的只是一个简单的白色页面,上面写着“未找到:/some_path”

它是这样的: https://skitch.com/jimmybaker/fq7js/https-fail

我正在使用 phusion Passenger + nginx + ree 部署我的 Rails 应用程序。我将我的 config.ru 文件放在我的 rails 应用程序的根目录下,如下所示:

#!/usr/bin/env ruby
require 'logger'
require 'config/environment'
require 'resque/server'

use Rack::ShowExceptions

# Set the AUTH env variable to your basic auth password to protect Resque.
AUTH_PASSWORD = 'xxxxxxx' || ENV['AUTH']
if AUTH_PASSWORD
  Resque::Server.use Rack::Auth::Basic do |username, password|
    password == AUTH_PASSWORD
  end
end

run Rack::URLMap.new \
  '/'       => ActionController::Dispatcher.new,
  '/resque' => Resque::Server.new

如您所见,我正在尝试加载 resque-web 前端以查看我的 redis 队列中的作业。同样,我能够访问 resque 前端,问题是这会破坏我的 rails 应用程序中所有需要 ssl 的控制器。

【问题讨论】:

    标签: ruby-on-rails nginx passenger redis resque


    【解决方案1】:

    我在这里有完全相同的东西,但我用了不同的方式:

    require File.dirname(__FILE__) + '/config/environment'
    require 'resque/server'
    
    Resque::Server.class_eval do
    
      use Rack::Auth::Basic do |username, password|
        begin
          user = User.authenticate( username, password )
          user && user.is_admin?
        rescue AuthenticatedSystem::InvalidLogin
          false
        end 
      end
    
    end
    
    app = Rack::Builder.new {
      use Rails::Rack::Static
    
      map "/resque" do
        run Resque::Server
      end
    
      map "/" do
        run ActionController::Dispatcher.new
      end
    }.to_app
    
    run app
    

    【讨论】:

    • 我还没有尝试过,但我很快就会尝试。你是说这能解决问题吗?我注意到您已经在 Rack::Builder 中的“/”之前映射了 /resque。我想知道这是否是关键..
    • 刚试了下还是一样的问题。我会在机架上学习一下,如果找到答案,我会发布。
    猜你喜欢
    • 1970-01-01
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多