sreyansjain

sreyansjain

Caddy is fantastic little production ready server that we can use instead of Apache or Nginx reverse proxy in front of multiple phoenix applications in one box.

The best thing is that we get https without needing to do anything on phoenix side. Caddy automatically provisions a certificate from Let’s encrypt.

All we need to do is just write one line of code.

Some important commands

sudo caddy start
sudo caddy stop
sudo caddy reload

Concept

We need to have a file Caddyfile (no extension) in the directory from where we would start the caddy server.

Say we have Caddyfile in the home directory - /home/sher

This is the content of the Caddyfile -

use.example.app {
        reverse_proxy * http://localhost:6001
}

test.example.app {
        reverse_proxy * http://localhost:8066
}
example.app {
        reverse_proxy * http://localhost:8000
}
another-site.com {
        reverse_proxy * http://localhost:4002
}

So we just need to write one line for each domain and our job is done.
Please note

test.example.app {
        reverse_proxy * http://localhost:8066
}

Here the phoenix app is still running in localhost but the final url would be https://test.example.app. This happens by magic. So you don’t need to do anything and https should automatically work.

This automatically gives you HTTP/2 which is faster than HTTP/1.1.

My Use case

I run a software development agency and we have several projects running in one box, so Caddy really helps there.

More advanced stuff is also possible. Check out the docs.

I found Caddy really interesting and thought that I should share it with the community.

P.S: I am not associated with Caddy in any way

Showing Posts 1 to 4

Exadra37

Exadra37

You also have the library site_encrypt from @sasajuric.

I am using Traefik for the same propose because I deploy with Docker.

If not in mistake Traefik uses Caddy under the hood.

rasputin303

rasputin303

I’m using Caddy as a reverse proxy for Phoenix too! I spent a weekend trying and failing to understand Nginx configs, Docker and so on, and eventually gave up. Then I found Caddy and all the SSL/LetsEncrypt stuff just works out of the box.

Kurisu

Kurisu

I’m also running a couple of umbrella phoenix apps in production with caddy-2 as reverse proxy. I really appreciate the simplicity of its configuration. I had a bit hard time figuring how to install it on ubuntu server, but I eventually find some good tutorials that helped me.

carterbryden

carterbryden

I love Caddy!

I’ve been building a small SAAS app with Elixir & Phoenix that makes heavy use of Caddy V2 and it’s been amazing to use. The app is an API for other apps that want to let their users connect custom domains or spin up subdomains on the fly. Each of my users gets their own dedicated Caddy instances that my app manages, and it’s worked flawlessly.

I’d really recommend checking out the JSON API as well as an alternative to using a Caddyfile. V2 has an admin API you can use to make updates while it’s running. Can’t recommend it enough.

Caddy is also built mostly by one person, Matt Holt, who can always use new sponsors on GitHub, if it’s working well for you :+1:. Great project to support.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
nseaSeb
AcmeScript — Writing JS hooks as if I were still using Elixir I’ve been having fun building a little something over the last few days: Ac...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews