mod_rails snippets

Symlinks for REE & mod_rails

Tagged symlink, mod_rails, rails  Languages bash
ln -fs /opt/ruby-enterprise-1.8.6-20090201 /opt/ruby-enterprise
ln -fs /opt/ruby-enterprise/bin/gem /usr/local/bin/gem
ln -fs /opt/ruby-enterprise/bin/irb /usr/local/bin/irb
ln -fs /opt/ruby-enterprise/bin/rake /usr/local/bin/rake
ln -fs /opt/ruby-enterprise/bin/rails /usr/local/bin/rails
ln -fs /opt/ruby-enterprise/bin/ruby /usr/local/bin/ruby

How to hide X-Powered-By and Server headers

Tagged servertokens, server, x-powered-by, mod_rails, passenger, apache, apache2, headers  Languages apacheconf

First enable the mod_headers module:

sudo a2enmod headers

Then add this to your apache2.conf:

# Hide X-Powered-By and Server headers
Header always unset "X-Powered-By"
ServerTokens Prod
ServerSignature Off

Now restart Apache:

/etc/init.d/apache2 force-reload

This is security through obscurity at it's finest...

PassengerPreStart, PassengerFriendlyErrorPages, and PassengerMinInstances - Three essential configuration parameters in Phusion Passenger 3.0

Tagged passengerprestart, passengermininstances, passengerfriendlyerrorpages, mod_rails  Languages ruby


This setting will make your users and the Google bot happy by starting your application as soon as Apache/nginx starts:


When combined with the PassengerMinInstances parameter, Passenger will keep at least one instance alive at all times:

PassengerMinInstances 1

This setting makes hackers unhappy by disabling Passenger's default error page, which contains sensitive information:

PassengerFriendlyErrorPages On

Read passenger's Apache documentation for details.


Passenger's nginx module has a slightly different naming convention:

passenger_min_instances 1
passenger_friendly_error_pages on

Plus you need to put the passenger_pre_start inside an http directive. I just put them all in passenger.conf:


If you don't put it where it belongs, you'll get this error:

Starting nginx: [emerg]: "passenger_pre_start" directive is not allowed here in /opt/nginx/conf/sites/

Read Passenger's nginx documentation for details.