Rails and ip-spoofing
I have small application on Rails 2.3.2, served with nginx+thin(127). OS FreeBSD 7.1, DB - Posgresql.
Twise at this week my app has fall. In log I get something like (~2-50 request per second):
/!\ FAILSAFE /!\ Mon Oct 04 20:13:55 +0300 2010
Status: 500 Internal Server Error
bad content body
/usr/home/../../history/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb:311:in `parse_multipart'
/usr/home/../../history/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb:125:in `POST'
/usr/home/../../history/vendor/rails/actionpack/lib/action_controller/request.rb:428:in `request_parameters'
/usr/home/../../history/vendor/rails/actionpack/lib/action_controller/request.rb:381:in `parameters'
/usr/home/../../history/vendor/rails/actionpack/lib/action_controller/base.rb:1279:in `assign_shortcuts'
/usr/home/../../history/vendor/rails/actionpack/lib/action_controller/base.rb:518:in `process_without_filters'
Or:
/!\ FAILSAFE /!\ Tue Nov 09 09:24:39 +0200 2010 Status: 500 Internal Server Error IP spoofing attack?! HTTP_CLIENT_IP="XX.XX.XX.XX" HTTP_X_FORWARDED_FOR="192.168.XX.XX, YY.YY.YY.YY"
/usr/home/../../history/vendor/rails/actionpack/lib/action_controller/request.rb:229:in `remote_ip'
/usr/home/../../history/vendor/rails/a开发者_开发问答ctionpack/lib/action_controller/base.rb:1372:in `request_origin'
/usr/home/../../history/vendor/rails/actionpack/lib/action_controller/base.rb:1304:in `log_processing_for_request_id'
/usr/home/../../history/vendor/rails/actionpack/lib/action_controller/base.rb:1296:in `log_processing'
/usr/home/../../history/vendor/rails/actionpack/lib/action_controller/base.rb:522:in `process_without_filters'
After that system rests into max open file limit (I guess it open by postgesql sessions), postgresql can't establish new connection and app fall.
Any suggestion, how I can protect my asspp in this situation?
Quoted from rails 2.3 release notes :
The fact that Rails checks for IP spoofing can be a nuisance for sites that do heavy traffic with cell phones, because their proxies don’t generally set things up right. If that’s you, you can now set ActionController::Base.ip_spoofing_check = false to disable the check entirely.
精彩评论