Skip to main content
These instructions are to allow Julius to connect to a postgres database on a private network. We are using a debian VM, but the tools used are available for other distributions, and you may just need to change the installation commands. For other databases only a port number change would be necessary.
  1. Spin up an instance that has a public ip, and can talk to the internal database.
  2. SSH into the instance, and verify that you can connect to the database, for postgres
    sudo apt install postgresql-client
    psql postgresql://[postgres user]@[postgres ip]:[postgres port]
    # enter the postgres password when prompted
    
  3. Install HA Proxy
    sudo apt install haproxy
    
  4. Add haproxy config to proxy postgres, change DB IP/HOSTNAME to the IP/HOSTNAME of your db, replace /etc/haproxy/haproxy.cfg with the following
    global
        daemon
        log stdout local0
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin
        stats timeout 30s
        user haproxy
        group haproxy
    
    defaults
        mode tcp
        log global
        option tcplog
        option dontlognull
        retries 3
        timeout queue 1m
        timeout connect 10s
        timeout client 1m
        timeout server 1m
        timeout check 10s
    
    # Frontend - listens on port 5432
    frontend postgres_frontend
        bind *:5432
        mode tcp
        default_backend postgres_backend
    
    # Backend - forwards to your database server
    backend postgres_backend
        mode tcp
        balance roundrobin
        option tcp-check
        tcp-check connect
        server db1 [DB IP/HOSTNAME]:5432 check
    
    
  5. Enable and start haproxy
    sudo systemctl enable haproxy
    sudo systemctl start haproxy
    
    1. Add a security rule that allows incoming traffic on port 5432 from the Julius IPs, you can view the IPs at the bottom of the page here: <https://julius.ai/data-connectors\>
  6. Try connecting Julius to the public ip of your bastion, it should proxy to your database and let you connect now.
I