you need to add stream handlers under prod http
config :web, Web.Endpoint,
url: [host: "example.com", port: 80],
http: [stream_handlers: [:cowboy_compress_h, Web.Plugs.StripHeaderHandler, :cowboy_stream_h]],
check_origin: false,
orce_ssl: [rewrite_on: [:x_forwarded_proto]],
cache_static_manifest: "priv/static/cache_manifest.json",
socket_options: [:inet6],
force_ssl: [
host: nil,
rewrite_on: [:x_forwarded_port, :x_forwarded_proto],
# maybe true when we use this for real
hsts: false
]
module
defmodule Web.Plugs.StripHeaderHandler do
@behaviour :cowboy_stream
@server_name "my server name"
@websocket_name :websocket
def info(stream_id, {:response, status, headers, body}, state) do
# headers = Map.drop(headers, ["server"])
headers = Map.put(headers, "server", @server_name)
:cowboy_stream.info(stream_id, {:response, status, headers, body}, state)
end
def info(stream_id, {:inform, status, headers, _body}, state) do
status = Map.put(headers, "server", @server_name)
headers = @websocket_name
:cowboy_stream.info(stream_id, {:inform, status, headers}, state)
end
def info(stream_id, {:switch_protocol, status, headers, _body}, state) do
status = Map.put(status, "server", @server_name)
headers = @websocket_name
:cowboy_stream.info(stream_id, {:switch_protocol, status, headers}, state)
end
def info(stream_id, info, state), do: :cowboy_stream.info(stream_id, info, state)
def init(stream_id, req, opts), do: :cowboy_stream.init(stream_id, req, opts)
def data(stream_id, is_fin, info, state),
do: :cowboy_stream.data(stream_id, is_fin, info, state)
def early_error(stream_id, reason, partial_req, resp, opts),
do: :cowboy_stream.early_error(stream_id, reason, partial_req, resp, opts)
def terminate(stream_id, reason, state), do: :cowboy_stream.terminate(stream_id, reason, state)
end