Heroku + SSL (own SSL, not the free version from Heroku)

I’m having a hard time getting Phoenix + Heroku + CloudFlare to play nicely with each other, maybe someone can help :slight_smile:

Here’s my config/prod.exs excerpt:

config :dotcom, Dotcom.Endpoint,
  http: [port: {:system, "PORT"}],
  url: [scheme: System.get_env("HEROKU_SCHEME"), host: System.get_env("HEROKU_HOST"), port: System.get_env("HEROKU_PORT"))],
  force_ssl: [rewrite_on: [:x_forwarded_proto]], (...)

Those Heroku ENV Vars are:
HEROKU_HOST = jonathansoifer.herokuapp.com

I bought an SSL certificated an also configured it on Heroku’s Dashboard:

Also setup CloudFlare’s DNS Tab:

And CloudFlare’s Crypto Tab:

Considering the above settings: it is not working (I’m redirect to Localhost when trying to access the site).

Now, I thought I should add additional settings and looking through the docs and doing some searches I ended up finding this:

I’m not sure how to fix this. Any help is appreciated.

just checking, but do you have MIX_ENV set to prod in heroku configuration variables?

a lot of stuff going on here, not sure what exact issue you are asking for help with.

your ssl is valid - https://www.ssllabs.com/ssltest/index.html
(though it looks like you have both cloudflare and heroku doing ssl, maybe toggle cloudflare ssl off on the orange cloud since you have your own cert)

both jonathansoifer.herokuapp.com and jonathansoifer.com returns identical “page not found” - so looks like things are working and it’s reaching your dyno?! but is phoenix deployed and have a root route? try and trail the log and see the dyno activity, and that it returns the 404… “heroku logs --tail -a jonathansoifer”

redirecting to localhost on your machine:
make sure you flush your dns cache, and make sure you don’t have something setup in your hosts file where your domain directs to localhost.

1 Like

Yup. In Heroku’s Procfile.

It was the local DNS cache. Thank you very much.

1 Like

I would actually recommend moving that to environment variable using heroku config:set MIX_ENV=prod

This is so you do not have to specify this every time you say want to use IEX to do some task from console.

1 Like