3

My Ruby on Rails site is throwing sporadic 502 errors. It is running on Nginx, installed with Passenger, and is hosted on a server running Ubuntu 10.04. It seems that the errors are becoming more and more sparse, but they're still causing a problem.

I am guessing that it has something to do with buffer size, but am not sure.

I know there are a few other questions on here from people with the same problem, but it seems to be very peculiar.

Thanks in advance for any help or suggestions. I can give you any specs or version numbers that you may need.

#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { passenger_root /usr/local/rvm/gems/ruby-1.9.3-p362/gems/passenger-3.0.18; passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-p362/ruby; include mime.types; default_type application/octet-stream; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; #buffer size proxy_buffers 8 16k; proxy_buffer_size 32k; passenger_buffers 8 16k; passenger_buffer_size 32k; passenger_max_pool_size 200; server { listen 80; server_name thelist.io; rails_env production; root /var/www/thelist.io/public; passenger_enabled on; } server { listen 80; server_name grant.XXXX.com; root /home/jackson/XXXX.XXXXX.com/; location / { index index.php; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one location ~ /\.ht { deny all; } } } 
1
  • Could you give some context? There's toooons of reasons for RoR 502s. Could be buffers, could be session headers too big, could be file permissions, bad routes, or db permissions. Commented Feb 6, 2013 at 2:13

1 Answer 1

1

The HTTP Error 502 means your application is not answering nginx on time, so you will probably need to scale it up.

When you use Rails, or other FastCGI server, such as PHP-FPM, nginx is the frontend.

So, nginx serves as a proxy, repassing the data to the FastCGI Server (Rails in your case).

Be sure that rails is using all it can from the serving machine, and if it don't fit with your request volume, you'll need to scale up (create more instances of the application server and distribute the webapp's tasks)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.