
gittech. site
for different kinds of informations and explorations.
Self-Host Supabase with Caddy and 2FA β Fully Automated
Supabase automated self host
Effortlessly deploy your own self-hosted, dockerized instance of Supabase with this fully automated setup script. This project simplifies the entire process, including the configuration of Caddy as a reverse proxy and Authelia for 2-factor authentication.
Note: This project isn't officially supported by Supabase. For any information regarding Supabase itself you can refer to their docs.
π If you find this project helpful, please consider leaving a β to show your support. You can also support my work by buying me a coffee. Thankyou!
Prerequisites
A Linux Machine with docker installed: This can be a server or any personal computer running Linux with at least 1 GB RAM and 25 GB Disk space. The script has been tested only on Linux/WSL.
Own Domain: A domain name is required only if you're going to expose supabase services to the internet. Otherwise you can run supabase locally (more on this in setup instructions)
Setup Instructions
If you prefer a visual guide, check out this video where I deploy a self hosted supabase instance with Authelia for 2FA to AWS in a few minutes:
Download
setup.sh
scriptcurl -o setup.sh https://raw.githubusercontent.com/singh-inder/supabase-automated-self-host/refs/heads/main/setup.sh
Make script executable
chmod +x setup.sh
Execute script
π If you only want basic username and password authentication
sudo ./setup.sh
π If you want 2-factor authentication setup with authelia
sudo ./setup.sh --with-authelia
During script execution, you'll be prompted to enter some details:
Enter your domain: Enter the domain name you want to access the supabase dashboard on. This is the host caddy server will listen for. Make sure to specify the
http/https
protocol. For example:https://supabase.example.com
β If you only want to access the dashboard locally, refer to this Guide
Enter username: Enter the username you want to use for authentication.
Enter password: Set a secure password.
Do you want to send confirmation emails to register users?
[y/n]
:If you enter "yes", Supabase will send a verification email to every new user who registers. You'll need to set up your own SMTP server and enter the config in
.env
file. You can read more about it here.If you enter "no", users will be able to signup with their email & password without any email verification. If you're only testing things out or don't want to send any verification/password-reset emails, enter "no"
The following additional prompts have to be answered only if you've enabled
--with-authelia
flag:Enter email: This email is used by authelia for setting up 2-factor auth / reset password flow. If you're not going to setup an SMTP server for emails, you can enter any email here. (When not using SMTP server, you can easily view codes sent by authelia in
docker/volumes/authelia/notifications.txt
)Enter Display Name: Used by authelia in emails and dashboard.
Do you want to setup redis with authelia? [y/n]: By default, authelia stores session data in memory. In layman terms: If authelia container dies for some reason every user will be logged out. If you're going to production, Authelia team recommends to use redis to store session data.
Thats it!
After script completes successfully, cd into supabase/docker
directory and run docker compose up -d
. Wait for containers to be healthy and you're good to go. To access dashboard outside your network, make sure that your firewall allows traffic on port 80 and 443.
Rate limits
By default, Supabase api routes don't have any rate-limits on the self hosted instance. You can easily rate-limit api routes using caddy server by following the steps HERE
supabase-automated-self-host vs. coolify: Key Differences
Coolify needs at least 2 GB RAM and 30 GB of disk space. Supabase itself only needs 1 GB ram and 25 GB disk space to start.
With coolify, you're only getting basic username password auth. No 2FA.
Coolify relies on Kong API Gateway by default, without a separate reverse proxy. This project configures Caddy as a reverse proxy, allowing easy rate-limiting. Support for multiple reverse proxies is also planned.
This script is definitely going to be faster than setting up through Coolify.
Personal bias here, I can't stand GUIs. With this, you get full control from the terminal, no clicking around, just a script that gets it done.
Where to ask for help?
- Open a new issue
- X/Twitter
- or stop by my Discord server anytime.
License
This project is licensed under the Apache 2.0 License.
Contributions
Feel free to open issues or submit pull requests if you have suggestions or improvements.