问题
I am trying to remove the server information from the http response header in my ruby on rails application running on Heroku but I am stuck. Inspecting the response headers gives me:
Server:thin 1.5.0 codename Knife
Can anyone point me in the right direction?
回答1:
This Server
header is set by the Thin server when assembling the response. A recent commit adds the ability to set the Server to something else, but it doesn’t look like you can totally remove it.
One thing you can do is to set the value of the Thin::VERSION
contsant to nil
, which results in no Server
header being sent:
Thin.send :remove_const, :SERVER
Thin::SERVER = nil
The first line is to avoid the warning that would be generated when altering a constant. Now when Thin tries to set the Server
header it sees it is nil
and skips it, so no header is set at all.
来源:https://stackoverflow.com/questions/13692701/how-to-remove-the-server-http-response-header-from-my-rack-app