views:

888

answers:

4

Hey folks,

I have a serious problem with one of our webservers... after having an internal alpha-testing with a mongrel/haproxy-cluster that worked well, we wanted to use nginx with passenger for our first production server (customers will access this server).

However, I can only run the rails app via development mode with passenger/nginx.

The app itself runs perfect with mongrel or webrick in production mode.

My biggest problem with this case is that I don't find ANY information in the nginx or rails-logs (only when I use mongrel or webrick).

Permissions are correct. Passenger-status shows that the app is running, but I always get the static 500.html-error page...

It would be so nice if you guys could give me a hint and help me solve the problem.

I put the config at the bottom of the post... This exact config works with rails_env development;but I'd like to use the production mode ;-)

Thank you very much for your help!


Version: Ubuntu 8.04.2 64bit / nginx-0.7.64 (compiled and installed via passenger-2.2.11)

cat /opt/nginx/conf/nginx.conf

user  www-data;
worker_processes  4;

error_log  logs/error.log;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
      passenger_root /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11;
      passenger_ruby /usr/bin/ruby1.8;


    passenger_log_level 3;
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  <<servername>>;


 root /srv/app01/public;
 passenger_enabled on;
}
A: 

Passenger with Nginx runs in production mode by default. Use the passenger-install-nginx-module command to install nginx compiled with the passenger module. Are you sure that you've created and migrated the database for production mode? rake db:create RAILS_ENV=production rake db:migrate RAILS_ENV=production

Your nginx.conf looks right to me. Make sure that the nginx user (E.g www-data) has access to your rails app.

Good luck

kamante
Hi, thanks for your answer... Database is setup properly and the file permissions should be right, because nginx+passenger works in development mode...Do you have any hints where I can find debug / log messages?
Michael W.
A: 

I run Rails 2.3.5 on Passenger behind nginx, and I've had the very same problem. My solution is always to switch over to development mode in Passenger/nginx or production mode in WEBrick to debug, but it sounds like you've tried both.

Did you try uncommenting the line error_log logs/error.log; in your nginx.conf?

Tom
Hi, thanks for your answer... What a shame, development mode is too slow for us, we want caching and all the stuff...I uncommented the line as you can see in the post above.Maybe we have to check what exactly is the issue (caching or whatever) by disabling some features and retrying...
Michael W.
I wouldn't recommend running in development permanently, just temporarily to find the cause of the error. Anyway, as far as I can tell, this is a Passenger bug. Frustrating.
Tom
A: 

just remove config.ru from your app directory

passenger will switch from rack to rails and everything will work

mag
A: 

It's a bug in Rails. The failsafe middleware doesn't properly flush the error message to the log files. I reported and fixed this issue a few months ago but they haven't released it yet: https://rails.lighthouseapp.com/projects/8994/tickets/3577-failsafe-middleware-should-flush-the-logger Apply the patch yourself and you should be able to see the error message in the logs.

Hongli