How to remove headers from fly.io proxy response?

I want to remove some of the headers that the fly.io proxy sends.

I want to remove:

  • the ‘via’ header
  • the ‘server’ header
  • the ‘fly-request-id’ header
  • and the ‘x-powered-by’ header

According to this thread that would be possible by adding a simple line to the fly.toml file:

...
[[services.ports]]
    ...
    http_options = { response = { headers = { via = false, x-powered-by = false, server = false, fly-request-id = false } } }
...

But if I deploy this fly.toml file nothing happens. The headers are still send from the fly.io proxy.

Could be a weird toml thing, I’ve had success with this format (watch your white space)

  [services.ports.http_options.response.headers]
    Via = false
    X-Powered-By = false

(I’m not sure if the Fly Proxy ignores this setting for certain headers, such as the request ID - someone can hopefully answer that if it becomes an issue).

Make sure you’re running a fly deploy after making any changes here.

1 Like

This may not be implemented properly for machine apps yet.

I am working on porting it atm

2 Likes

Thanks for your answers!

I will definitely take a look at @fideloper-fly‘s solution and hope I will have success with it.

I will answer to this topic what my results were.

I would definitely appreciate if fly.io would implement that to work with all headers.

Thanks!

Have a nice day!

stay tuned. the fix will be released soon Port services.ports.http_options to v2 apps by dangra · Pull Request #2169 · superfly/flyctl · GitHub

Ok, it took longer than expected but here it is, upgrade to flyctl v0.0.541 and redeploy :rocket:

4 Likes

It finally worked!

Thank you!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.