How to hide nginx version in elastic beanstalk

Question:

I am running an app on the platform Ruby 2.2 (Passenger Standalone) and wish to hide the nginx version from the HTTP headers. I am not using Docker. Other Stack Overflow answers have recommended adding this to my .ebextensions:

00_nginx.conf:

However this does nothing. Should I be putting the file in a different spot?

Answer:

AWS Elastic Beanstalk with Ruby 2.2 + Passenger Standalone 1.4.3 doesn’t use (original) Nginx 1.6.2. It uses Passenger Standalone 1.4.3 server, which is modified version of Nginx 1.6.2.

So, if you want to modify the Nginx config, you must edit the Passenger Standalone config. The Passenger Standalone config is located at $(passenger-config about resourcesdir)/templates/standalone/config.erb.

You can use following .ebextensions:

00-passenger.config:

The above config will check the Passanger config for server_tokens off;. If server_tokens off; isn’t set, we add server_tokens off; and passenger_show_version_in_header off; just below (append) http {.

Before:

After:

NOTE: The above config only affect if the Passenger is (re)-started. So, you need to terminate your current instance.

Leave a Reply