/vps

Primary LanguageElixir

VPS

This Elixir project is a meta-project that ties together 4 different Phoenix applications and runs them all on a single instance of the BEAM that is running Nerves on a Vultr (affiliate link) VM.

It powers the following Phoenix sites:

I spoke about this at CodeBEAM America 2022: https://codebeamamerica.com/participants/Jason-axelson/

At this time the video is not available, but the slides are available at: https://jasonaxelson.com/talks/codebeam2022

How does it work?

The base system runs on Vultr via nerves_system_vultr. MainProxy allows for multiple Phoenix applications to run on a single BEAM instance on the same port (443 in this case). The domain name on the incoming request is what ties a request to a specific Phoenix Endpoint.

Note: I'm currently using my own branch, but I plan to re-integrate that into main_proxy https://github.com/axelson/main_proxy/tree/flexiblity-1

Site Encrypt provides automated https certificate management via LetsEncrypt.

It's important to me to not store secrets inside the repository so I use a simple Config.Provider to load /data/.target.secret.exs at runtime. I manage that file on the VM so I can deploy from multiple computers.

SSHSubsystemFwup allows for easy deploys over SSH with a simple mix upload command.

Why Vultr

Honestly it's primarily because nerves_system_vultr exists and is the only maintained way to run a nerves instance on a cloud provider. But I have found Vultr to be a good and cost-effective host for my hobby projects.

Running locally

Run locally with:

mix deps.get
iex -S mix phx.server

Then add the following lines to your /etc/hosts file:

127.0.0.1 depviz.localhost
127.0.0.1 makeuplive.localhost
127.0.0.1 sketch.localhost
127.0.0.1 jamroom.localhost

Then you can open the following in a web browser:

Note: you can change the port away from the default of 4102 by setting config :main_proxy, http: [:inet6, port: <a new port>]

In your ~/.ssh/config file I recommend setting:

Host vultr
HostName <your-vultr-server-ip-address>

Maybe try this locally (nginx SSL passthrough) https://sxi.io/how-to-configure-nginx-ssl-tls-passthrough-with-tcp-load-balancing/

Deployment

See the Development instructions