New Feature: Basic HTTP response header modification

We’ve just released a way to modify your HTTP response headers in a limited, but useful, fashion.

Essentially, this new features allows you to either add or remove headers via fly.toml like so:

[[services.ports]]
handlers = ["http"]
port = "80"
# here it is
http_options = { response = { headers = { to-add = "value", to-remove = false } } }

In this case, the to-add: value would be added to the response headers. The to-remove header would be removed from the final response our proxy sends to your users.

You can use the new http_options.response.headers map to:

Add a header

# add the header `my-header: value` to HTTP responses
http_options = { response = { headers = { my-header = "value" } } }

or for multiple-values headers

# depending on the HTTP version, the header output will be different
http_options = { response = { headers = { my-header = ["value1", "value2"] } } }

Remove a header

# remove the `via` header (automatically added by Fly)
http_options = { response = { headers = { via = false } } }
5 Likes

Hey @jerome, do you have any more info on this feature? Specifically do you know if it’s possible to remove the fly-request-id and change server header? I can’t seem to get consistent results with the above code.

Thanks,
Joseph

Just want to know if we can add runtime environment to the response header like fly machine id?