38
votes

I would like to set some SSL certificates for one app I have on heroku (a simple application based on nodeJS + Vue).

I know if I upgrade to the Hobby Plan (7$ for month) I can have it automatically.

But for now it would too much money for a test application, so I am wondering if I can achieve some similar goal also with a Free Plan.

so: Is it possible to set SSL certificate for an app on Heroku JUST with the Free Plan? Maybe in a complicated/tricky way via CLI?

From the Heroku pages and documentation it looks not possible. But I have to ask :)

9
This question will become even more important since "Starting January 11, 2021, automatically generated certificates (using Heroku ACM) used for TLS/HTTPS termination on Heroku will become incompatible with most software running on Android versions prior to v.7.1.1 (around 34% of currently active Android devices)."J0ANMM

9 Answers

35
votes

Here I have a better approach to deal with this. As Heroku Doesn't provide SSL for Free Plan. But You can use Cloudflare which gives free SSL. You can Use Cloudflare As Bridge For SSL.

Requirement: 1. Cloudflare Account 2. Your Application should not have inbuild SSL redirection (like redirect-ssl) Otherwise, This will result in Too Many Redirect Error

Step 1: Point Your domain to CloudFlare. You basically open an account an enter your domain when prompted. You may be given instructions to change your domain name servers.

Step 2: Add Cname Record of Heroku Server in DNS of Cloudflare. Instructions are here Here You will get Some SSL Security Issue.

Step 3: Now Change Your SSL/TLS encryption mode to Flexible (Not Full). *Important enter image description here

Now Understand the Working:-

Client(Browser) Make Request to https://example.com First, the request reaches the Cloudflare with SSL. (User see encrypted connection to the server.)

Then Cloudflare makes request to Heroku Server(Origin) with Non-SSL (Non-Https and Unencrypted).

Then Heroku Server (Origin) returns the Response with Non-SSL to Cloudflare.

At the end Cloudflare forward the request to Client (Browser.)


I have tested this method and working on https://www.foneman.in

23
votes

Late response but I'm adding here I just spent an hour trying to setup SSL with Heroku - resulting in a dead end.

The bottom line is that Heroku mentions they offer free SSL certificates but that's really not the case unless you have a Hobby ($7/mo) or Pro plan.

This link has more details and feedback from other users facing the same issue.

The answer above about LetsEncrypt is incorrect. Although you can get a free certificate, it cannot be included in a free Heroku app.

Other users have pointed to this article with a step-by-step guide but the guide is outdated and the 'Labs' option mentioned does not work with Heroku anymore.

see comments below for some alternative suggestions

In my specific case, I was able to get a free SSL on zeit.

16
votes

Here's how you get FULL SSL using Cloudflare for FREE.

enter image description here

Step 1: Point Your domain to CloudFlare. You basically open an account an enter your domain when prompted. You may be given instructions to change your domain name servers.

Step 2: Add Cname Record of Heroku Server in DNS of Cloudflare. Instructions are here. Here You will get Some SSL Security Issue.

Step 3: Now Change Your SSL/TLS encryption mode to Full

Step 4: In your DNS settings, you’ll want to create a CNAME: yourdomain.com -> yourapp.herokuapp.com.

(I learned about the general approach here https://mikecoutermarsh.com/adding-ssl-to-heroku-with-cloudflare/ Although it's old, it still works.

6
votes

I had this issue also. I wanted to set up a custom domain for my free account on Heroku for my React App. I searched so much info on the web and read loads of documents from Heroku support.

The conclusion is that on the Heroku free account, a custom domain name with SSL certificate cannot be setup. If you need SSL with your custom domain name, you need to upgrade to any of their paid hosting accounts.

Heroku does provide SSL certificate for their free account as long as it is not using a custom domain name. So the standard free account URL will be something like this "https://your-app-name.herokuapp.com"

NB. Google Firebase allows free hosting and Custom Domain name with SSL, for up to a certain amount of traffic before charging. For testing an app, this will be a perfect alternative. I am using it. And it was easy to set up my custom domain.

I hope this saves you hours of searching.

5
votes

Since you don't make explicit if you need to apply the SSL certificate to a custom domain, I think it's necessary to say that according to the Heroku documentation:

Apps using free dynos can use the *.herokuapp.com certificate if they need SSL.

https://devcenter.heroku.com/articles/ssl

Maybe future readers could find this answer helpful...

4
votes

If you are using

1]free heroku,

You can't use 1)free ssl or 2)paid ssl

2]paid heroku

1)you get free ssl 2)you can use paid ssl also

Solution 1]get paid heroku 2]move to netlify or other alternatives

3
votes

Free SSL in Heroku doesn't exist, or let me just say that it's impossible to achieve it on a free plan.

For you to be able to include any form of third party SSL in Heroku, be it paid SSL or Free Third Party SSL, you have to change to Hobby or Professional dynos for the SSL to work.

An easier option, if you're using Heroku, there's no need to buy a third party SSL. Just change to Hobby or Professional dynos.

For you to be able to change the dyno type, select your app, go to sources section on the upper part, just bellow it, click on the Change Dyno Type button.

Hobby Dyno will cost you $7 a month while Professional Dyno will cost you $25 - $500 a month.

After all that, remember to go to your Rails App: Go to; .../config/environments/production.rb

--> Uncomment the following line:

# config.force_ssl = true

---> To:

config.force_ssl = true

After that, you'll be able to achieve your SSL but not FREE.

1
votes

If you don't mind hosting your frontend on another service you can host it in Vercel, with free SSL, while you keep your backend at Heroku. Quite straightforward!

https://vercel.com/

0
votes

One way around this could be setting up a proxy server on a host you can set SSL certificates on and then simply forward requests to the free herokudns domain using encryption as well.

You'd have to have a separate server with something like nginx or httpd running.. I am not sure of a free service to host the proxy, but usually when you sign up for a domain you may get a hosting addon with it, or perhaps people already have acess to an encrypted host and just want to also use Heroku for their node applications.

Setting up a httpd proxy would look somewhat like this (from https://serverfault.com/questions/84821/apache-proxypass-with-ssl):

<VirtualHost 1.2.3.4:80>
ServerName customdomain.com
SSLProxyEngine On
SSLProxyCheckPeerCN on
SSLProxyCheckPeerExpire on
ProxyPass / https://heroku-app-name.herokuapp.com
ProxyPassReverse / https://heroku-app-name.herokuapp.com
</VirtualHost>

This way you have full encryption all the way :)