Infinite redirect loop is not removed by fixed re-deploys

I’ve introduced a redirect loop for my application from www.domain.name to same www.domain.name. Now even if I comment out all the code responsible for this, the behavior is still the same, as if re-deploying on fly doesn’t really fix the issue. Although in fly logs I see a proper answer from my phoenix server when doing curl -I on my domain:

2022-06-18T05:46:41Z app[2195ce6d] fra [info]05:46:41.182 [info] Plug.SSL is redirecting HEAD / to https://www.domain.name with status 301

When I use same docker build locally, this doesn’t happen, I can clearly see that the code doesn’t redirect it. Does fly cache permanent redirects and can I flush it?

I have tried re-creating the app with the same https certificates and it results in the same error. So the code deployed fine, this is something DNS related or fly-cache related. The fact that fly logs gives this line even without the code responsible for this gives me a reason to think that fly caches permanent redirects.

Browsers cache permanent redirects.

Have you tried a different browser? Or curl, which won’t cache it.

We don’t do any caching at all.

The log line appears to come from your app. Given the “Plug.SSL" bit.

Thanks a lot for your reply! I’ve finally solved this, the reason was that in my config/prod.exs there was a setting

config :wind_world_web, WindWorldWeb.Endpoint,
  force_ssl: [hsts: true]

which probably assumes that there are paths to certificates in the config file present which is not the case with letsencrypt used by fly. So I added infinite redirect loop logic in two places with both force_ssl and my own code, that’s why commenting my code didn’t yield any effect.

1 Like