131
loading...
This website collects cookies to deliver better user experience
More database space - by using your own VPS, you could have a database that is many times bigger than what is (currently) available via Supabase managed platform
Full infrastructure control - you're in control of everything so if you need to make a change, you have that option
It's already setup - You don't have to have a significant level of technical knowledge to setup a Supabase instance on their platform
Costs - They offer a free plan which may be enough for your needs
db.example.com
as our domain name. This will be mentioned later in the Nginx configuration section.docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
http://<ip-of-your-vps>:9000
and follow the on-screen instructions.nginx-config
and nginx-data
, and then use those from the volumes
tab when setting up Nginx./docker/docker-compose.yml
.OPERATOR_TOKEN=your-super-secret-operator-token
JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
POSTGRES_PASSWORD=your-super-secret-and-long-postgres-password
# some SMTP server to send your auth-mails with
SMTP_HOST=mail.example.com
SMTP_PORT=
SMTP_USER=
SMTP_PASS=
.env
file.supabase-rest
container, set the hostname to rest
. You can set this to anything you like, but I recommend keeping it relevant to the container. Finally, click 'Deploy this container'. It will warn you that a container with the same name already exists - click 'OK'. After a short while, the container will be redeployed with the new hostname. Repeat these steps for each Supabase container.DATABASE_URL
will include sslmode=disable
. The equals sign in this value may cause errors. For example, if you try to call the .signUp()
method from the supabase-js library, you may get an error 500. The reason for this is that it will attempt to connect to disable
instead of postgres://<db_user>:<password>@db:<db_port>/postgres?sslmode=disable
sslmode=disable
and any other query parameters from the URL.cd
your way to the volume where your Nginx config is stored. If you set up a nginx-config
volume as mentioned above, this will (usually) be located at /var/lib/docker/volumes/nginx-config/_data
.nginx.conf
.http
section, add the following:map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server realtime:4000;
}
conf.d/default.conf
. There's many ways you can configure Nginx, but for the sake of simplicity, we're going to keep this to a single file.conf.d/default.conf
, replace the entire contents with the following:server {
listen 443 ssl;
server_name db.example.com;
# REST
location ~ ^/rest/v1/(.*)$ {
proxy_set_header Host $host;
proxy_pass http://kong:8000;
proxy_redirect off;
}
# AUTH
location ~ ^/auth/v1/(.*)$ {
proxy_set_header Host $host;
proxy_pass http://kong:8000;
proxy_redirect off;
}
# REALTIME
location ~ ^/realtime/v1/(.*)$ {
proxy_redirect off;
proxy_pass http://kong:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
}
}
/rest/v1
path, as well as anything added after that part of the path. It is then routing it to the Supabase Kong server, which by default will be accessible internally at http://kong:8000
./auth/v1
, and routing them also to Kong./realtime/v1
route. Again, this routes to Kong.@supabase/supabase-js
) are able to correctly route to the different services in the stack.supabase_default
network - the option to do this is found at the bottom of that page in the dashboard.kong-data
./var/lib/kong
. Then click on the 'Volume' button to the right side of it.GOTRUE_OPERATOR_TOKEN=your-super-secret-operator-token
GOTRUE_JWT_DEFAULT_GROUP_NAME=authenticated
# Make sure this JWT secret matches what was configured during setup
GOTRUE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
# How long should JWT tokens be valid for?
GOTRUE_JWT_EXP=3600
# Since Supabase is based on Postgres, you shouldn't need to change this
GOTRUE_DB_DRIVER=postgres
# What schema should requests be routed to?
# There should be no reason to change this
DB_NAMESPACE=auth
# Where is our auth/GoTrue located
# You shouldn't need to change these unless the ports are mapped differently
GOTRUE_API_HOST=0.0.0.0
PORT=9999
# Email settings
# You must set these if you want to be able to send emails
GOTRUE_SMTP_HOST=smtp.your-email-host.com
GOTRUE_SMTP_PORT=465
GOTRUE_SMTP_USER=your-smtp-user
GOTRUE_SMTP_PASS=your-smtp-password
# Should users be required to confirm their email address before they can log in?
# If set to false, users won't have to confirm their registration
# If set to true, users will have to click the link in their email to confirm
GOTRUE_MAILER_AUTOCONFIRM=false
# What is the 'from' address that emails are sent from?
GOTRUE_SMTP_ADMIN_EMAIL=[email protected]
# Remove this if you don't want debug logs
GOTRUE_LOG_LEVEL=debug
# The connection string for your database
# `@db` says we're looking for the container called 'db' on our docker network
DATABASE_URL=postgres://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres
# Email templates
# Invite user - provide a URL to a HTML or Text template
GOTRUE_MAILER_TEMPLATES_INVITE=https://example.com/path/to/your/invite/template.html
# Confirm registration - provide a URL to a HTML or Text template
GOTRUE_MAILER_TEMPLATES_CONFIRMATION=https://example.com/path/to/your/confirmation/template.html
# Password recovery - provide a URL to a HTML or Text template
GOTRUE_MAILER_TEMPLATES_RECOVERY=https://example.com/path/to/your/password_reset/template.HTML
# Magic link - provide a URL to a HTML or Text template
GOTRUE_MAILER_TEMPLATES_MAGIC_LINK=https://example.com/path/to/your/magic_link/template.html
# GoTrue URLs
# These are appended after the API_EXTERNAL_URL
# You shouldn't need to change these
GOTRUE_MAILER_URLPATHS_CONFIRMATION=/auth/v1/verify
GOTRUE_MAILER_URLPATHS_INVITE=/auth/v1/verify
GOTRUE_MAILER_URLPATHS_CONFIRMATION=/auth/v1/verify
GOTRUE_MAILER_URLPATHS_RECOVERY=/auth/v1/verify
# Site URLs
# This is where the user will be redirected to after clicking a link in an email and after oAuth
GOTRUE_SITE_URL=https://example.com/redirect_to_here
GOTRUE_URI_ALLOW_LIST=https://example.com/redirect_to_here
# This is the URL where your supabase stack is accessible
# i.e. this is the endpoint URL you would pass into a `createClient()` call in the supabase-js library
API_EXTERNAL_URL=https://database.example.com/
# Set this to true if you want to prevent signing up with email and password
GOTRUE_DISABLE_SIGNUP=true
# oAuth
# If you are not using oAuth to login (e.g. Login with Facebook), you can ignore the below
# If you want to disable oAuth for a specific provider, set the `GOTRUE_EXTERNAL_<provider>_ENABLED` to false
# Github oAuth
GOTRUE_EXTERNAL_GITHUB_CLIENT_ID=your_github_client_id
GOTRUE_EXTERNAL_GITHUB_SECRET=your_github_client_secret
GOTRUE_EXTERNAL_GITHUB_ENABLED=true
# Google oAuth
GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
GOTRUE_EXTERNAL_GOOGLE_SECRET=your-google-secret
GOTRUE_EXTERNAL_GOOGLE_ENABLED=true
# Facebook oAuth
GOTRUE_EXTERNAL_FACEBOOK_CLIENT_ID=your-facebook-client-id
GOTRUE_EXTERNAL_FACEBOOK_SECRET=your-facebook-app-secret
GOTRUE_EXTERNAL_FACEBOOK_ENABLED=true
# Add other oAuth provider details below
postgres
and the postgres password you setup inside the environmental variables.