Skip to content

fly-apps/mpg-jump-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fly.io Postgres Proxy

TCP proxy to expose Fly.io Managed Postgres databases over public networking.

This is a simple proxy example if you need to expose a Fly.io Managed Postgres database over public networking.

⚠️ Instead of this we strongly recommend connecting to your database by deploying your application to the same Fly.io organization as your database or by connecting over wireguard. ⚠️

We don't currently directly support public networking for Fly.io Managed Postgres databases.

Setup

  1. Clone and prepare

    git clone <repo>
    cd fly-postgres-proxy
    go mod tidy
  2. Set primary region to match database region in fly.toml

  3. Create Fly app

    fly apps create your-postgres-proxy
  4. Set database URL

    fly mpg attach <cluster-id> --app your-postgres-proxy
  5. Deploy

    # make sure you allocate IPs - you likely want a v4, and v6
    # `fly deploy` should offer this otherwise you can use `fly ips allocate-v4` and `fly ips allocate-v6`
    fly deploy

Usage

Connect to your database through the proxy:

# Using psql
psql postgresql://user:[email protected]:5432/dbname

# Using any Postgres client
host: your-postgres-proxy.fly.dev
port: 5432
user: your_db_user
password: your_db_password
database: your_db_name

How it works

The proxy runs in your Fly.io organization with access to the private WireGuard network. It forwards TCP connections from the public internet to your private Postgres instance.

Security

This exposes your database publicly. Consider IP restrictions for production use.

About

Example app to expose your Fly.io Managed Postgres cluster to the public internet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published