Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passenger+Nginx show custom 500 page

I'm using Rails 3.2 with passenger+nginx. I want to display nice custom 500 page when the db server is down. I want to show something when my rails app cannot be started. Here is my nginx:

server {
  listen 80;
  server_name localhost;
  root /var/www/store/public;
  error_page   500  /500.html;

  # root
  location / {
    passenger_enabled on;
    rails_env production;
    passenger_use_global_queue on;
  }

}

The above configuration doesn't work at all. When it happens, it shows only:

Internal Server Error (500)

Any idea?

like image 731
Chamnap Avatar asked Oct 12 '12 10:10

Chamnap


3 Answers

Phusion Passenger author here. Use passenger_intercept_errors off.

like image 152
Hongli Avatar answered Nov 06 '22 03:11

Hongli


from the passenger documentation http://www.modrails.com/documentation/Users%20guide%20Nginx.html#PassengerFriendlyErrorPages

passenger_friendly_error_pages off

Which can be placed inside the http block, server block or location block, will not show the passenger error for startup failures and I believe link to the nginx supplied 500 error page.

like image 23
danmanstx Avatar answered Nov 06 '22 02:11

danmanstx


mariow's link led me to the answer. The error files are in the templates folder. I use rvm, so my templates folder is at /home/forest.handford/.rvm/gems/ruby-2.0.0-p481/gems/passenger-4.0.50/resources/templates/ . Use find / -name templates | grep passenger to find yours. I'm changing undisclosed_error.html.template for my site, as it is the error that occurs when people type an invalid URL .

like image 1
Forest J. Handford Avatar answered Nov 06 '22 04:11

Forest J. Handford