I couldn't find any way to disable Passenger's X-Powered-By
header:
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11
Is it possible to do that without modifying its sources and removing headers on the HTTP server level?
I couldn't find any way to disable Passenger's X-Powered-By
header:
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11
Is it possible to do that without modifying its sources and removing headers on the HTTP server level?
There is no configuration option in passenger to disable the X-Powered-by, so you need to do one of
#RequestHandler::process_request
headers_output = [
STATUS, status.to_i.to_s, CRLF,
X_POWERED_BY, @passenger_header, CRLF
]
#AbstractRequestHandler::initialize
@passenger_header = determine_passenger_header
#AbstractRequestHandler::determine_passenger_header
def determine_passenger_header
header = "Phusion Passenger (mod_rails/mod_rack)"
if @options["show_version_in_header"]
header << " #{VERSION_STRING}"
end
if File.exist?("#{SOURCE_ROOT}/enterprisey.txt") ||
File.exist?("/etc/passenger_enterprisey.txt")
header << ", Enterprise Edition"
end
return header
end
passenger_show_version_in_header off;
now exists. –
Apprehensive more_clear_headers
on Nginx or Header always unset
on Apache –
Apprehensive On Apache you can unset headers:
# Hide/Remove the Passenger Headers
Header always unset "X-Powered-By"
Header always unset "X-Runtime"
It will not remove all names (since services such as Plesk will still append their name), but Passenger can be removed this way.
Kudos to John Trupiano: https://groups.google.com/forum/?fromgroups=#!topic/phusion-passenger/LKAKH0PEyW0
a2enmod headers
–
Glyptic Short answer: YES.
update: 2018
Use proxy_hide_header
if downstream, or use more_clear_headers
Original Answer
I leave the fact that I use nginx+passenger .. but you can completely remove them with
remove_header X-Header-Name-To-Remove;
So you can remove both by
server {
...
remove_header X-Powered-By;
remove_header X-Runtime;
...
}
This removes all the headers, it can also be in a location directive instead of server.
..
Here are my common directives, as I leave 'apache prod' equiv on mine.
server {
...
remove_header X-Runtime;
server_tokens off;
passenger_show_version_in_header off;
...
}
Provides a service header like..
Server:nginx + Phusion Passenger
X-Powered-By:Phusion Passenger
This is the closest equiv of apache2 ServerTokens Prod directive that I can do.
passenger_show_version_in_header
is passenger configuration, remove_header
is ngnix directive, and makes this answer not very correct –
Peri remove_header
didn't work. I used more_clear_headers
of HttpHeadersMoreModule (from nginx-extras
package) and it worked ! –
Apprehensive nginx: [emerg] unknown directive "remove_header"
–
Supertanker There is no configuration option in passenger to disable the X-Powered-by, so you need to do one of
#RequestHandler::process_request
headers_output = [
STATUS, status.to_i.to_s, CRLF,
X_POWERED_BY, @passenger_header, CRLF
]
#AbstractRequestHandler::initialize
@passenger_header = determine_passenger_header
#AbstractRequestHandler::determine_passenger_header
def determine_passenger_header
header = "Phusion Passenger (mod_rails/mod_rack)"
if @options["show_version_in_header"]
header << " #{VERSION_STRING}"
end
if File.exist?("#{SOURCE_ROOT}/enterprisey.txt") ||
File.exist?("/etc/passenger_enterprisey.txt")
header << ", Enterprise Edition"
end
return header
end
passenger_show_version_in_header off;
now exists. –
Apprehensive more_clear_headers
on Nginx or Header always unset
on Apache –
Apprehensive more_clear_headers 'Server' 'X-Powered-By' 'X-Runtime';
works for me as mentioned in http://www.michaelrigart.be/en/blog/nginx-and-passenger-install-in-production-environment.html.
To completely remove X-Powered-By
and Server
headers from Nginx+Passenger and not just hide versions, add this to your http
block in nginx.conf
:
server_tokens off;
more_clear_headers Server;
more_clear_headers X-Powered-By;
You could also set your own:
more_set_headers "Server: ACME";
This will work even if passenger_show_version_in_header off;
is not set, but it might be smart to add it as well in case.
Remember to restart the server for these to take affect. You should test your config before restart though: sudo nginx -t
.
Information via calvin.my
© 2022 - 2024 — McMap. All rights reserved.