jerry

jerry

Elixir API deployment with SSL

Hello Team,

I have developed an Elixir API and preparing to deploy into production.

Can I get some help on how I can enable TLSv1.2 with all the other accompanying options?
Do I necessarily have to use Nginx in order to achieve a complete TLS configuration?

Thanks in advance.

Regards,

Jerry

Most Liked

dch

dch

FWIW I would never ever recommend running raw Erlang/OTP on the internet apart from hobby apps, I always use a dedicated load balancer (haproxy, nginx, traefik, …):

  • crypto is expensive, the LB provides very efficient TLS termination without clogging up your OTP apps
  • crypto is hard, the LB have this as a core priority. If you read the last 3 years of OTP related code for TLS you will see quality & valiant efforts to keep up with the status quo but it’s always trailing what the LB can provide. If there is a security issue with a mainstream LB you can be certain it will be fixed in a handful of days.
  • LB are really good at doing LB. Simple things like handling blue/green deployments, switching nodes for maintenance, dealing with malicious traffic, rate limiting, are easiest done right at the point of contact with your infrastructure. If you have a LB squashing a bad user, your app can perform properly for all other users without constraints. If not, your rate limiting activities have to compete with your valid users
  • when you need to update TLS certificates, or change connection parameters, you’ll not need to have to take your app down to do so.

At the end of the day, these 4 reasons are just 1 reason: separation of concerns is a good thing. Use the right tool for the job. Do TLS termination with a process that is designed fro this. Same for load balancing of end-user requests.

michalmuskala

michalmuskala

I wonder how this consideration of trade-offs changes when you start considering http2 and the fact that many popular LB/proxy solutions (Nginx and AWS ELB for example) don’t forward http2 - they downgrade the traffic between the balancer and server to http1.

dch

dch

It’s very much a case of measuring and optimising your deployment. Simply pouring HTTP2 everywhere and waiting for a significant improvement is unlikely to help much.

For example:

If you have your LB configured correctly, then you already have multiple persistent open HTTP/1.1 connections between the LB and your app server, that will remain open across many request/response cycles. There is very little gain to be had from multiplexed backend connections, and you have no TLS nor TCP setup/teardown cost.

However, prioritised streams, compressed headers, and server push can make a significant difference on the client side, and I am not at all clear how a LB impacts this yet. Some functionality appears to require end-to-end HTTP2.

Kazuho's Weblog: HTTP/2 (and H2O) improves user experience over HTTP/1.1 or SPDY has some old but useful data - 30% improvement in time to first paint, with substantial time spent configuring the server, including attempting to work around bugs in the prioritisation logic on the client side. While one hopes this has improved substantially since 2015, the inconsistent results between browsers is unlikely to have changed.

In projects like https://h2o.examp1e.net/ there are quite a few settings available to tune these, but I don’t think we have this sort of flexibility yet in Phoenix and Cowboy. It would be an interesting project for some organisation to fund.

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54921 245
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement