Configure Clojure web app to run with HTTPS support on Amazon Beanstalk

Intro

However, if your web app needs SSL support on custom domain you immediately need to pay $20/month for the Heroku addon.

The second option is to host your Clojure web app on Amazon EC2. This can be done almost for free for the first year if your app is small enough. Check out AWS Free Usage Tier. Hosting web app on Amazon EC2 has its own upsides and downsides.

The third solution (probably, there are many other options out there) is the one, that I want to describe in this post.

How to setup custom domain (naked domain) for Beanstalk application

I recommend to use Amazon Route 53 for managing DNS records. If you have a hosted zone on Amazon Route 53 for your domain name, then you need just to create new Record set of type A.

Select "Yes" for "Alias" field and you will be able to select Elastic Load balancer that works with your Beanstalk instance in the "Alias target" field.

After this is done you will be able to reach your web app using naked domain name (e.x. example.com instead of www.example.com).

How to configure HTTPS support for you Beanstalk application

There is a nice article in Amazon docs about how to add HTTPS support for your Beanstalk application.

You need to upload your SSL certificate using command aws iam upload-server-certificate --server-certificate-name $NAME --certificate-body file://$FILE_NAME.crt --private-key file://$FILE_NAME.key You will get Amazon Resource name for your certificate similar to arn:aws:iam::123456789012:server-certificate/cert

After uploading SSL certificate you need to edit configuration for your Beanstalk app. In the "Load balancer" section specify:

Secure listener port: 443

Protocol: HTTPS

SSL Certificate ID: Amazon Resource name that you received after certificate upload.

Conclusion

In this post I tried to describe steps needed to have Clojure web app deployed to Amazon Beanstalk and make it available behind your own secure naked domain.