2012-06-01 58 views
3

我上傳了一個簡單的Sinatra應用程序到AppFog。它在我的本地機器上運行良好。但是,在將應用上傳到AppFog後,當訪問AppFog domain時,會顯示一個帶有「Forbidden」消息的頁面。當我訪問AppFog上的Sinatra應用程序時顯示「Forbidden」消息

這些appFog日誌:

====> /logs/stderr.log <==== 
... 
W, [2012-06-01T06:32:54.008426 #28933] WARN -- : attack prevented by Rack::Protection::IPSpoofing 
211.32.146.42 - - [01/Jun/2012 06:32:54] "GET/HTTP/1.1" 403 - 0.0002 
10.0.64.157 - - [01/Jun/2012:06:32:54 UTC] "GET/HTTP/1.0" 403 9 - ->/
W, [2012-06-01T06:32:54.393022 #28933] WARN -- : attack prevented by Rack::Protection::IPSpoofing 
211.32.146.42 - - [01/Jun/2012 06:32:54] "GET /favicon.ico HTTP/1.1" 403 - 0.0002 
10.0.64.157 - - [01/Jun/2012:06:32:54 UTC] "GET /favicon.ico HTTP/1.0" 403 9 - -> /favicon.ico 

我沒有在我的代碼使用Rack::Protection::IPSpoofing,但我得到這些錯誤。 Rack::Utils用於幫助程序塊。這是造成這個問題嗎?

唯一的Ruby代碼我寫的是以下幾點:

require 'sinatra' 
require 'data_mapper' 
require 'builder' 
require 'sinatra/flash' 
require 'sinatra/redirect_with_flash' 
require 'haml' 

enable :sessions 

SITE_TITLE = "Recall" 
SITE_DESCRIPTION = "'cause you're too busy to remember" 

DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/recall.db") 

class Note 
    include DataMapper::Resource 
    property :id, Serial 
    property :content, Text, :required => true 
    property :complete, Boolean, :required => true, :default => false 
    property :created_at, DateTime 
    property :updated_at, DateTime 
end 

DataMapper.finalize.auto_upgrade! 

helpers do 
    include Rack::Utils 
    alias_method :h, :escape_html 
end 

get '/' do 
    @notes = Note.all :order => :id.desc 
    @title = 'All Notes' 
    if @notes.empty? 
    flash[:error] = 'No notes found. Add your first below.' 
    end 
    haml :home 
end 

# ... 

您可以檢查出整個源代碼here

我該如何解決這個問題?感謝您的任何建議。

+0

僅供參考,它適用於[雲代工廠](http://recall.cloudfoundry.com/) – philipjkim

+0

FWIW,它也給我禁止。我會試着直接問他們。它們似乎是在你的代碼中注入模塊(類似於Heroku在它的Bamboo堆棧上做的事情,它們是用Cedar改變的)。他們的文檔對我來說似乎很缺乏,所以我認爲直接詢問他們會是最好的。 (或嘗試Heroku,這是我的其他想法:) –

+0

這也發生在EngineYard託管 –

回答

5

這是一個簡單的辦法,你可以添加以下:

set :protection, :except => :ip_spoofing 

我們很快修補我們的nginx來解決這個問題,但解決此工作將有助於現在。

+0

感謝您的答案。問題解決了! – philipjkim

相關問題