Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Mar 14, 2013 5:29 am 
Offline

Joined: Thu Mar 14, 2013 5:23 am
Posts: 1
Hi,
I recently set up a NodeBalancer in front of a Rails 3.2.12 app.
The app is served by nginx and Unicorn.

All seems to work fine, but I get a lot of errors such as theses that I didn't get when I only had 1 server.

Code:
IP spoofing attack?!HTTP_CLIENT_IP="10.16.81.184"HTTP_X_FORWARDED_FOR="136.160.88.153, 192.168.255.5"
actionpack (3.2.12) lib/action_dispatch/middleware/remote_ip.rb:55:in `calculate_ip'


Here is my nginx configuration for the app.

Code:
upstream unicorn {
server unix:/tmp/unicorn.ahotu-calendars.sock fail_timeout=0;
}

server {
listen 80 default deferred;
root /home/deployer/apps/appdirectory/current/public;
if (-f $document_root/system/maintenance.html) {
return 503;
}
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}

location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}

try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}

error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}


Did I do something wrong?

Thank you


Top
   
PostPosted: Wed Apr 03, 2013 8:08 pm 
Offline
Senior Member
User avatar

Joined: Thu Feb 16, 2012 9:01 pm
Posts: 52
Looks like Rails having trouble with 2 X-Forward-For addresses.

The nodebalancer adds an X-Forwarded-For header, that they haven't document despite me bugging them about it numberious times.

In my nginx setup I've got the following in a server that replaces the source IP for only the nodebalancer. I don't know if it removes the proxy header:

real_ip_header X-Forwarded-For;
set_real_ip_from 192.168.255.0/24;

If you still have problems try to overwride the X-Forwarded-For rather than adding an address.


Top
   
PostPosted: Wed May 22, 2013 1:29 am 
Offline
Senior Member
User avatar

Joined: Thu Feb 16, 2012 9:01 pm
Posts: 52
Finally documented: https://library.linode.com/nodebalancers/reference


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group