DEV Community

Cover image for Harnessing the Power of Self-Hosted Supabase on Coolify: A Complete Guide to Server Setup and OAuth Providers Integration
Musa Yazlık
Musa Yazlık

Posted on

Harnessing the Power of Self-Hosted Supabase on Coolify: A Complete Guide to Server Setup and OAuth Providers Integration

Supabase is one of the great tools you can choose for back-end development in a project. One of its advantages is that you can self-host it on your own server. However, I believe there is a lack of documentation when it comes to configuration. I'm using Coolify, a service similar to Vercel, on my own server, and you can easily set up Supabase with this service.

However, I spent quite a bit of time setting up the auth service, but eventually, I succeeded. In this post, I will guide you through how to configure the auth provider settings for your self-hosted Supabase on Coolify.

Let's get started…

I will proceed assuming that you have already set up and running the Supabase service in Coolify. Once inside the service, click on the "Environment Variables" menu in the left sidebar. Then, click the "Developer view" button.

At the bottom of the opened section, enter the following values. For demonstration purposes, I used Google as the provider. If you want to add GitHub instead, you can replace "GOOGLE" with your desired provider name, such as "GITHUB." You will also need to fill in the value fields according to your own setup.

ENABLE_GOOGLE_SIGNUP=true
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CALLBACK_URI=https://supabase.domain.com/auth/v1/callback
Enter fullscreen mode Exit fullscreen mode

Now, we're getting to the main point. Since Supabase runs under Docker, we need to make edits in the compose file. To do this, go to the "Service stack" menu and click the button I've highlighted with an arrow. This will open a window where you can make the necessary edits.

Image description

In the opened window, find "supabase-auth," which should be on line 193. Go to the "environment" section. Add the following code just above the "realtime-dev:" section at the bottom. Make sure to follow the correct indentation for the code. Afterward, save the file.

      - 'GOTRUE_EXTERNAL_GOOGLE_ENABLED=${ENABLE_GOOGLE_SIGNUP}'
      - 'GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}'
      - 'GOTRUE_EXTERNAL_GOOGLE_SECRET=${GOOGLE_CLIENT_SECRET}'
      - 'GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI=${GOOGLE_CALLBACK_URI}'
Enter fullscreen mode Exit fullscreen mode

Image description

Now, one final adjustment is needed. On the "Environment Variables" page, change the value of the "SERVICE_FQDN_SUPABASEKONG" field to the callback URL you want to redirect to, and don't forget to save it. For example: "https://domain.com/auth/callback".

Image description

Finally, we need to reset the service. Once the service restarts, the auth provider you want to use in Supabase will be ready to go.

This brings us to the end of this guide. I've tried my best to explain how to add and set up auth providers for the Supabase service you've set up on Coolify.

If you need paid support in this area or for web development, you can contact me through the addresses below. See you in the next post…☺️

✉️ E-mail: support@musayazlik.com
Fiverr: https://www.fiverr.com/musayazlik

Top comments (0)