I configured my application to redirect from HTTP to HTTPS but now when I try to access it from the browser I get an error that it redirected too many times. When I run the container locally it only redirects once as expected so why is it causing errors on Aptible?
Per the HTTP(S) Endpoints documentation:
[HTTP(S) Endpoints] handle HTTPS termination (and optionally redirect HTTP traffic to HTTPS), and pass it on as HTTP traffic to your app Containers.
Since the application always sees the protocol as
http even when the Endpoint is accessed using
https, it’s redirecting from
https indefinitely (AKA a redirect loop).
The recommended method for redirecting from HTTP to HTTPS is to configure the App with
FORCE_SSL=true. Doing this and removing the redirection from your application should solve the problem. See the HTTPS Redirect documentation for more details.
If you would like to access the original protocol in the application, you can retrieve it from the the
X-Forwarded-Proto header. The main thing to watch out for is that Health Checks always connect via HTTP. By default, this won’t be an issue but if you enable Strict Health Checks you’ll need to allow HTTP on
/healthcheck or health checks will fail as discussed in this topic.