How I deploy my backends (as of Nov 2026)
Intro
My tech stack is in constant evolution as my SaaS requirement evolves. This articles describes how and why I’m currently deploying my backends as of November 2026
Current requirements
- multiple projects with less than 100 API requests per day
- need decent security (I should be the only one able to deploy to my servers, to read the databases, and to administrate the applications, VPS provider is the only trusted 3rd party)
- need to easily and quickly create new projects
- need to easily and quickly deploy changes to my projects
- need to have a test environment I can safely destroy
- can’t afford unpredictable operating costs, and would like to avoid useless costs
Out of scope
- frontend (covered here)
- application-specific logic (covered in blog posts specific to each project)
- my object-oriented Python databases (covered in the future)
- CI/CD (I’m just self-hosting a Gitea server on an old Thinkpad, it handles CI/CD, PyPi, Docker and many other registries natively)
- monitoring (I’m using self-hosted Umami for analytics, Prometheus for metrics, Loki for logs, Grafana for dashboards, and Sentry for bugs)
Cloud architecture
TL;DR: I rent 2 VPS in the cloud for a few euros per month. One prod and one staging. Each hosting several services using Docker containers. Some services externalized to 3rd party cloud providers like AWS or GCP.
Server VS serverless
At first was tempted to use Cloudflare serverless free tier, as I could eaily run my projects there for free. But quickly decided to instead host my own servers because I prefered predictable cost of 10 euros per month rather than free until it explodes before I have paying users. Sorry guys you’ll never see me listed in Serverless Horrors!
Functions/BaaS VS containers
But the tradeoff server VS serverless isn’t done yet: even with my own server I could still self-host serverless applications using for example OpenFaaS (an AWS-lambda alternative).
After giving a try to a few self-hostable AWS-lambda or Vercel alternatives: tried OpenFaaS and PocketBase, realized I prefered to have full control on the runtime of my applications rather than using a BaaS to manage my backend. So I decided to use Docker containers to ship my services.
Plain Docker VS PaaS
Next tradeoff: should I administrate myself my Docker containers and:
- learn about docker networking
- learn about linux server administration and security
- learn about docker swarm
- debug alone why docker isn’t dockering at 3AM
- handle myself database, backups, replication, scaling…
Or: use a PaaS to handle all of that trouble for me?
Gave a try to Coolify and Dokploy. 2 very nice software! My projects were actually running fine. But at the end decided to handle raw containers myself.
I felt like PaaS were hiding technical stuff under the carpet. Similarly to my BaaS VS containers tradeoff: I prefered to fully own and understand the infrastructure of my services. I want to fully be aware of any security risk I take, to fully understand how things work. Not ask Claude to review Coolify or Dokploy’s source code at 3AM to understand if my certificates are stored securely.
Running several services on one server
To be clear about definitions: one server is one VPS (or an old Thinkpad at home), with its own IP address and Linux OS. One service is a backend application that usually has an API exposed to one or more domain names.
Since I need to run serveral services, it means one server will receive requests from many APIs, and different containers will handle them.
Routing API requests from different domain names to one server: easy. Just put the server’s IP in the A DNS records. Routing to the correct container: need a reverse proxy.
First tried Ngnix, but didn’t like that to keep my services fully secure I had to add many configuration myself, 0-downtime configuration changes aren’t straightforward, and felt like it was pretty complex.
At the end decided to use Traefik instead. Feels ultra-simple to manage securely, especially with Ansible.
In order to route requests to relevant containers, the Traefik container needs to be on the same Docker network as the containers that will handle the requests.
I’m currnetly running 19 containers on dual-core VPS, running fine given my current requirement as each individual container doesn’t need much RAM or CPU when idle.
Other cloud services
Although I would love to self-host everything myself, still some services are deletaged:
- LLM is delegated to GCP (Gemini) and OpenAI: I don’t want to buy ultra-expensive GPUs
- Database offsite backup is delegated to AWS (S3): wanted a super reliable backup storage on top of the Thinkpad I’m using as server at home
- Frontends are delegated to Cloudflare Pages. I would need to pay a lot of servers to reach the quality level of their CDN.
- Mails are delegated to Resend. Self-hosting a mail server is easy, convincing every major email service my server isn’t spam is difficult.
- Bugs are delegated to Sentry
Infrastructure summary
Here is a simplified overview of the infrastructure: prod on the left and staging on the right. To simplify, only 2 projects are shown (Moopro and No Bullshit Happiness), but as of today each of my server is hosting 7 personal projects plus self-hosted services like Gitea, Docker registry, Grafana, Umami…
flowchart TB
User(["🧑 End user"])
Me(["🧑💻 Myself (admin)"])
subgraph Staging["Staging VPS"]
direction TB
TraefikStaging["Traefik<br/>ports 80 / 443"]
MooproStaging["moopro"]
NbhStaging["nobullshithappiness"]
PgMooproStaging[("PostgreSQL")]
PgNbhStaging[("PostgreSQL")]
TraefikStaging -->|"api.test.moopro.sonibla.com<br/>admin.test.moopro.sonibla.com"| MooproStaging
TraefikStaging -->|"api.test.nobullshithappiness.com<br/>admin.test.nobullshithappiness.com"| NbhStaging
MooproStaging <--> PgMooproStaging
NbhStaging <--> PgNbhStaging
end
subgraph Prod["Prod VPS"]
direction TB
TraefikProd["Traefik<br/>ports 80 / 443"]
MooproProd["moopro"]
NbhProd["nobullshithappiness"]
PgMooproProd[("PostgreSQL")]
PgNbhProd[("PostgreSQL")]
TraefikProd -->|"api.moopro.sonibla.com<br/>admin.moopro.sonibla.com"| MooproProd
TraefikProd -->|"api.nobullshithappiness.com<br/>admin.nobullshithappiness.com"| NbhProd
MooproProd <--> PgMooproProd
NbhProd <--> PgNbhProd
end
Cloud["External cloud services<br/>(LLM APIs, S3 backups, Resend...)"]
User -->|"api.moopro.sonibla.com / api.nobullshithappiness.com"| TraefikProd
Me -->|"admin.moopro.sonibla.com / admin.nobullshithappiness.com"| TraefikProd
Me -->|"admin.test.moopro.sonibla.com / admin.test.nobullshithappiness.com"| TraefikStaging
MooproStaging --> Cloud
NbhStaging --> Cloud
MooproProd --> Cloud
NbhProd --> CloudAdministration
TL;DR: services are all deployed as docker containers, deployment simplified with Ansible, for security SSH keys are stored in a different VM than the one running Ansible playbooks, private endpoints (admin API and UI, staging) are protected by mTLS
Firewalls
Nothing special to say, the VM I use to administrate my servers is only allowed to reach my servers’ IP address, and the server-side firewall restricts the SSH ports to be reachable only by myself.
SSH authentication
In order to run any command on the servers (even if it’s ran by Ansible), I’m using SSH authentication. This is needed to start the containers after populating the project’s files.
The classical way of doing it is: the server knows the public key, the client has the encrypted private key, and uses it to authenticate. During authenitcation, the key is decrypted (password typed by the user) and stored plain-text in RAM.
But I like defense in depth, so instead of doing that, my server still holds the public key, but the private key is stored in an offline VM, different than the one used to connect to my servers. Cryptographic operations also happen in the offline VM, so the VM that’s connected to the servers never sees the private key or its password, not even in RAM. This is possible thanks to Qubes OS and Split SSH
flowchart TB
Me(["🧑💻 Myself"])
subgraph Qubes["Qubes OS"]
direction TB
NetVM["<b>Network-connected VM</b><br/>runs ssh client / Ansible"]
FwClient{{"🛡️ <b>Firewall</b><br/>only allowed to reach<br/>the server's IP"}}
OfflineVM["<b>Offline VM</b><br/>holds the private key<br/>encrypted at rest"]
NetVM <-->|"Split SSH<br/>(qrexec)<br/>signing request / signature only"| OfflineVM
NetVM -->|"SSH"| FwClient
end
subgraph ServerBox["Server"]
direction TB
FwServer{{"🛡️ <b>Firewall</b><br/>SSH port only reachable<br/>from my IP"}}
Sshd["<b>sshd</b><br/>holds the public key"]
FwServer --> Sshd
end
Me -->|"Run Ansible"| NetVM
Me -->|"Unlock key"| OfflineVM
FwClient -->|"Encrypted connection"| FwServermTLS authentication
Regular TLS only authenticates the server. With mTLS, the server also authenticates the client. This is handled by my Traefik container (the only container listneing on ports 80 and 443). This ensures I’m the only one able to reach sensitive endpoints.
Example: my Umami admin dashboard is protected by mTLS. This means even if my Umami password leaked or if there was a bug in Umami’s authentication, the admin UI and API would still be protected. This is of course on top of firewalls only allowing my IP address to reach the admin endpoint.
flowchart TB
User(["🧑 Legitimate end user<br/>no client cert"])
Me(["🧑💻 Myself<br/>holds client cert"])
Stranger(["🕵️ Anyone else<br/>no client cert"])
subgraph VPS["Server"]
direction TB
Traefik["<b>Traefik</b><br/>ports 80 / 443"]
App["<b>moopro</b><br/>API + admin UI"]
Traefik -->|"api.moopro.sonibla.com<br/>public, TLS only"| App
Traefik -->|"admin.moopro.sonibla.com<br/>mTLS-enforced"| App
end
User -->|"TLS"| Traefik
Me -->|"mTLS"| Traefik
Stranger -.->|"mTLS<br/>❌ rejected: no/invalid cert"| TraefikPublic endpoints (api.*) only need regular TLS, so any client can reach them. Private endpoints (admin.*) are configured in Traefik to require a valid client certificate during the TLS handshake. Used moopro for the example, but all of my projects are following this pattern.
In order to filter which client can access what service, for each project I’m creating a root certificate authority and intermediaries certificate authorities. Private keys are always stored in a dedicated offline VM.
In order to manage all my OpenSSL certificates I’m currently using homemade plain bash scripts (which are open source!). Implementing a secure OpenSSL certificate manager is a project for later though!
Ansible
Initially I sent the project’s files to the server with scp and ran docker compose up -d manually. Turned out it was worth it to tearn Ansible. To handle all the repititive tasks, especially to template configuration files and avoid copy-pastes between projects. Also Ansible lets me securely store sensitive files (openssl certificates) in git repositories using Ansible Vault.
Currently my Ansible playbooks and roles:
- render all project files from templates
- drop project-specific configuration to relevant folders for Traefik and Prometheus
- deploy Docker containers
- handle database backup and restore
Here is a relevant extract of the main.yml file that deploys my projects:
- name: Ensure destination directory exists
ansible.builtin.file:
path: "{{ backend_deploy_path }}"
state: directory
owner: root
group: root
mode: "0755"
- name: Render compose.yml from template
ansible.builtin.template:
src: compose.yml.j2
dest: "{{ backend_deploy_path }}/compose.yml"
mode: "0644"
- name: Render and deploy app .env
ansible.builtin.template:
src: .env.j2
dest: "{{ backend_deploy_path }}/.env"
mode: "0600"
- name: Create and start application containers (api + worker)
tags: [compose]
community.docker.docker_compose_v2:
project_src: "{{ backend_deploy_path }}"
project_name: "{{ project_name }}-backend"
files: "{{ ['compose.yml'] }}"
pull: "always"
recreate: "always"
remove_orphans: true
state: present
- name: Drop backend Traefik routes
tags: [dynamic]
ansible.builtin.include_role:
name: traefik
tasks_from: route
vars:
traefik_route_name: "{{ project_name }}-backend"
traefik_route_template: traefik.yml.j2
- name: Drop backend Prometheus targets
tags: [dynamic]
ansible.builtin.include_role:
name: monitoring
tasks_from: target
vars:
monitoring_target_name: "{{ project_name }}-backend"
monitoring_target_template: prometheus-targets.yml.j2Next step
Next improvement on my todo list, already deployed on my homelab but not yet on my 2 VPS: Wireguard VPN, on top of firewalls, mTLS and SSH. Defense in depth!