Changing the default error page for Nginx passengers

Currently, if there is a problem when starting the Rails application on our server, users go to the Passenger error page with an error, because the application "Ruby (Rack) cannot be started".

Can I customize this page with an error and display something else so that users of this site do not see this?

I am using nginx for the server.

thanks

+6
source share
2 answers

When testing Passenger 5.1, I found that setting passenger_friendly_error_pages off not enough to change the default error page. This disables the exposure of backtrace or environment variables, but still shows the Passenger error page.

To solve this problem, I had to install the following:

 passenger_intercept_errors on; error_page 500 /500.html; 

The passenger_intercept_errors command tells nginx to process status codes 400 or higher. The error_page command configures the error. You can also configure other errors.

For a Rails application, the page layout refers to the public folder of the application (which you set in the root command for nginx).

As already mentioned, this comment is a similar configuration for Apache:

 PassengerErrorOverride on ErrorDocument 500 /path/to/500.html 
+1
source

The user manual contains some useful information about various configuration options. There is an option to disable friendly error pages , which I think you can see.

To disable the startup error message, specify the following line in the configuration file:

 passenger_friendly_error_pages off 

You can place this in the http block, server block, or location block. If you put it in an http block, it will disable it by default for all virtual hosts on this server. However, you can override the setting in the server block by putting the same option inside the http block.

+9
source

Source: https://habr.com/ru/post/902858/


All Articles