QuotaGuard and Koyeb Integration Guide

    QuotaGuard and Koyeb Integration Guide

    QuotaGuard Static IPs allow your services on Koyeb to send outbound traffic through a load-balanced pair of static IP addresses. Once set up, you can use QuotaGuard’s IPs to connect to IP-restricted databases and APIs outside your Koyeb network.

    You do not need QuotaGuard to connect between services within your Koyeb private network.

    Getting Started

    After creating a QuotaGuard account, you will be redirected to your dashboard where you can find your proxy credentials and static IP addresses.

    Choose the right proxy region: For Koyeb’s Frankfurt (fra) region, select QuotaGuard’s EU proxy. For Washington D.C. (was), select US-East. This minimizes latency.

    To check your Koyeb service’s region, run:

    koyeb services list
    

    Look for the REGION column in the output.

    Configuring Your Application

    Step 1: Add Your Proxy URL as a Secret

    Store your QuotaGuard credentials securely using Koyeb secrets:

    koyeb secrets create QUOTAGUARDSTATIC_URL --value "http://username:password@us-east-static-01.quotaguard.com:9293"
    

    Step 2: Reference the Secret in Your Service

    When deploying or updating your service, reference the secret as an environment variable:

    koyeb apps init my-app \
      --git github.com/myorg/myrepo \
      --env "QUOTAGUARDSTATIC_URL="
    

    Or update an existing service:

    koyeb services update my-app/my-service \
      --env "QUOTAGUARDSTATIC_URL="
    

    Step 3: Configure Your HTTP Client

    Python (requests)

    import os
    import requests
    
    proxy_url = os.environ.get('QUOTAGUARDSTATIC_URL')
    
    proxies = {
        'http': proxy_url,
        'https': proxy_url
    }
    
    response = requests.get('https://api.example.com/data', proxies=proxies)
    print(response.json())
    

    Node.js (axios)

    const axios = require('axios');
    const { HttpsProxyAgent } = require('https-proxy-agent');
    
    const proxyUrl = process.env.QUOTAGUARDSTATIC_URL;
    const agent = new HttpsProxyAgent(proxyUrl);
    
    axios.get('https://api.example.com/data', { httpsAgent: agent })
      .then(response => console.log(response.data));
    

    Install the proxy agent: npm install https-proxy-agent

    Node.js (fetch with undici)

    import { ProxyAgent, fetch } from 'undici';
    
    const proxyUrl = process.env.QUOTAGUARDSTATIC_URL;
    const dispatcher = new ProxyAgent(proxyUrl);
    
    const response = await fetch('https://api.example.com/data', { dispatcher });
    const data = await response.json();
    

    Go

    package main
    
    import (
        "fmt"
        "net/http"
        "net/url"
        "os"
    )
    
    func main() {
        proxyURL, _ := url.Parse(os.Getenv("QUOTAGUARDSTATIC_URL"))
        
        client := &http.Client{
            Transport: &http.Transport{
                Proxy: http.ProxyURL(proxyURL),
            },
        }
        
        resp, err := client.Get("https://api.example.com/data")
        if err != nil {
            panic(err)
        }
        defer resp.Body.Close()
        
        fmt.Println("Status:", resp.Status)
    }
    

    Ruby

    require 'net/http'
    require 'uri'
    
    proxy_uri = URI.parse(ENV['QUOTAGUARDSTATIC_URL'])
    
    http = Net::HTTP.new(
      'api.example.com', 
      443, 
      proxy_uri.host, 
      proxy_uri.port, 
      proxy_uri.user, 
      proxy_uri.password
    )
    http.use_ssl = true
    
    response = http.get('/data')
    puts response.body
    

    Database Connections (SOCKS5)

    For non-HTTP protocols like PostgreSQL, MySQL, or MongoDB, use our SOCKS5 proxy.

    Step 1: Create a SOCKS Secret

    Your SOCKS proxy URL is available in your QuotaGuard dashboard. Add it as a separate secret:

    koyeb secrets create QUOTAGUARD_SOCKS_HOST --value "us-east-static-01.quotaguard.com:1080"
    koyeb secrets create QUOTAGUARD_SOCKS_USER --value "your-username"
    koyeb secrets create QUOTAGUARD_SOCKS_PASS --value "your-password"
    

    Step 2: Configure Your Database Client

    Python (PostgreSQL with psycopg2 and socks)

    import os
    import socks
    import socket
    import psycopg2
    
    # Configure SOCKS proxy
    socks.set_default_proxy(
        socks.SOCKS5,
        os.environ.get('QUOTAGUARD_SOCKS_HOST').split(':')[0],
        int(os.environ.get('QUOTAGUARD_SOCKS_HOST').split(':')[1]),
        username=os.environ.get('QUOTAGUARD_SOCKS_USER'),
        password=os.environ.get('QUOTAGUARD_SOCKS_PASS')
    )
    socket.socket = socks.socksocket
    
    # Connect to database
    conn = psycopg2.connect(
        host='your-database.example.com',
        database='mydb',
        user='dbuser',
        password='dbpass'
    )
    

    Install dependencies: pip install PySocks psycopg2-binary

    Testing Your Implementation

    Requests to ip.quotaguard.com always return the client’s IP address. Use this to verify your proxy configuration:

    # From your local machine with the proxy URL
    curl -x $QUOTAGUARDSTATIC_URL https://ip.quotaguard.com
    

    Expected response:

    {"ip":"52.34.188.175"}
    

    The IP should match one of the static IPs shown in your QuotaGuard dashboard.

    Latency Considerations

    Using QuotaGuard adds an additional network hop to your requests. Typical latency impact:

    • Same region (e.g., Koyeb fra + QuotaGuard EU): 10-20ms
    • Cross-region: 50-100ms

    For latency-sensitive applications, always match your QuotaGuard proxy region to your Koyeb deployment region.

    Troubleshooting

    407 Proxy Authentication Required Your credentials are incorrect. Double-check the username and password in your QUOTAGUARDSTATIC_URL secret.

    Connection Timeout Ensure your Koyeb service can reach external networks. Check that you’re not blocking outbound traffic in any network policies.

    Wrong IP Address Returned The proxy URL might not be correctly configured in your HTTP client. Verify the environment variable is being read correctly.


    Ready to Get Started?

    Get in touch or create a free trial account.

    Try QuotaGuard Now


    Ready to Get Started?

    Get in touch or create a free trial account