Fastly CDN Heroku URL redirecting

269 views Asked by At

I recently added Fastly domain from addons in Heroku application. And when Fastly was provisioned I got a test URL which is as follows:

https://felix-homes-herokuapp-com.global.ssl.fastly.net/

Whenever I click on this url it gets redirected to

https://felix-homes.herokuapp.com for some unknown reason.

Note my nodejs app uses Heroku-SSL-Redirect. Is it because of this?

I have already followed setup guide and asked multiple issues from the support

https://support.fastly.com/hc/en-us/requests/323620?page=1

And nearest question I find to SO is following

Adding Fastly to a Heroku app does not forward to proper url

Clearing browser cache or changing browser did not help me. Can you please try hitting Fastly URL on your computer and let me know if you are also face same redirect problem?

1

There are 1 answers

1
Denis Cornehl On

Yes, very likely the library (Heroku-SSL-Redirect) is the issue.

In the end, you have two separate requests. An encrypted HTTPS/SSL request from the browser. And then an unencrypted request from Fastly to Heroku.

Your node-application and the library only see the unencrypted request and return the redirect.

There are two ways to solve this:

  1. You configure Fastly do do encrypted requests to Heroku as its backend.
  2. Every routing / proxy layer (fastly, but also the Heroku routing layer) typically use the X-Forwarded-Proto HTTP header to tell the backend application that the initial request was already encrypted. So either heroku-ssl-redirect doesn't look at the header, or it did get lost somewhere on way.