Closed wizardfrag closed 11 years ago
Ahh yes, you're right.
The error is happening on https://github.com/christiangenco/dbinbox/blob/0032068f748c5ca4c6f8c2f5647e18230e5be4ba/app.rb#L281
Not sure what the fix for this would be. Wanna take a crack at it?
The code should work fine. This is most likely a configuration issue. Make sure your proxy is sending the X_FORWARDED_FOR
header. In nginx you should just be able to add a line:
include proxy_params
to the location that defines the proxy_pass
Here's what I have right now in nginx:
157 upstream dbinbox.com{
158 server 127.0.0.1:3200;
159 }·
160 server{
161 listen 80;
162 server_name dbinbox.com;
163 client_max_body_size 100M;
164 root /u/apps/dbinbox/current/;
165 access_log /u/apps/dbinbox/current/log/thin.log;
166 error_log /u/apps/dbinbox/current/log/error.log;
167 location / {
168 proxy_pass http://dbinbox.com;
169 }
170 error_page 500 502 503 504 /50x.html;
171 }
Do I just add include proxy_params
below line 168?
Oh hey! That fixed it. I did this instead, but I think it's functionally equivalent:
157 upstream dbinbox.com{
158 server 127.0.0.1:3200;
159 }·
160 server{
161 listen 80;
162 server_name dbinbox.com;
163 client_max_body_size 100M;
164 root /u/apps/dbinbox/current/;
165 access_log /u/apps/dbinbox/current/log/thin.log;
166 error_log /u/apps/dbinbox/current/log/error.log;
167 location / {
168 proxy_pass http://dbinbox.com;
169 proxy_set_header Host $host;
170 proxy_set_header X-Real-IP $remote_addr;
171 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
172 }
173 error_page 500 502 503 504 /50x.html;
174 }
When uploading a text file via the "send message" interface, the file shows as such:
This, obviously, is not the IP address it was uploaded from. Seems to be caused by a proxy in front of this application.