Fly proxy throws a 502 even with fly-prefer-region header

I am using the following configuration in nginx to proxy connections to the correct machine:

client_max_body_size 50M;

location / {
    add_header Fly-Replay "app=my-app;instance=XXXXXXXXXXX";
    add_header fly-prefer-region "ams";
    return 303 "route to client app";
  }

The proxying works fine.
Unfortunately, the proxy returns a 502 when the payload (POSTing a big file) is bigger than 1mb. Accordings to the docs, a workaround is telling the proxy where to route the request by using the fly-prefer-region header, which I do. Still, the request does not reach the target machine and my browser shows the 502 response from the fly proxy.

How can I make this work? Or is it simply not possible to combine instance=XXXX with fly-prefer-region?

Hi!

the docs for fly-replay explicitly detail a 1-MB limit when using that header, and they specifically mention using fly-prefer-region if you need larger requests handled in a specific region (though for large requests you won’t be able to pick a particular instance).

Did you try using only fly-prefer-region without fly-replay?

Cheers,

  • Daniel

Thank you for your answer.

Unfortunately, I do need to route the request to a specific machine. My setup / use case is managing lots of differently configured copies of a django app with user storages and I think keeping them all in one fly app is the most reasonable approach.

I am now investigating the complexity of writing my own gateway/proxy application with openresty because the fly-proxy replaying the requests is slow (adds 700ms to each single request, like assets and navigation) and I need more flexibility at the proxy level (fail-over strategy for when a machine won’t auto-start due to insufficient available host memory).

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