### Install golang.org/x/net/proxy Source: https://www.quotaguard.com/docs/databases/postgresql/supabase-network-restrictions Install the Go SOCKS5 proxy package required for the pgx example. ```bash go get golang.org/x/net/proxy ``` -------------------------------- ### Install pg and socks Source: https://www.quotaguard.com/docs/databases/postgresql/supabase-network-restrictions Install the pg and socks packages required for the Node.js example. ```bash npm install pg socks ``` -------------------------------- ### Node.js: Install pg and socks packages Source: https://www.quotaguard.com/docs/databases/postgresql/neon-ip-allow Installs the pg client and socks library required for the custom stream example. ```bash npm install pg socks ``` -------------------------------- ### Install undici Source: https://www.quotaguard.com/docs/platforms/emergent/emergent-integration Install the undici package, which is required for the native fetch example. ```bash npm install undici ``` -------------------------------- ### Go: Install golang.org/x/net/proxy package Source: https://www.quotaguard.com/docs/databases/mongodb/atlas-integration Command to install the Go proxy package required for the SOCKS5 dialer example. ```bash go get golang.org/x/net/proxy ``` -------------------------------- ### Run Application Under QGTunnel - Render Start Command Source: https://www.quotaguard.com/docs/databases/postgresql/supabase-network-restrictions Render start command to run the application under QGTunnel. ```bash bin/qgtunnel npm start ``` -------------------------------- ### Ruby: Install mongo and socksify gems Source: https://www.quotaguard.com/docs/databases/mongodb/atlas-integration Installs the mongo and socksify gems needed for the Ruby MongoDB SOCKS proxy example. ```bash gem install mongo socksify ``` -------------------------------- ### Install https-proxy-agent for Node.js Source: https://www.quotaguard.com/docs/platforms/aws/lambda-integration Command to install the required https-proxy-agent package for the Node.js examples. ```bash npm install https-proxy-agent ``` -------------------------------- ### Wrap Retool start command with qgtunnel Source: https://www.quotaguard.com/docs/platforms/retool/retool-integration Use this command to start Retool with QGTunnel. It wraps the original start command so that database connections are intercepted and routed through QuotaGuard static IPs. ```bash /app/bin/qgtunnel node_modules/.bin/retool-start ``` -------------------------------- ### Example output when restrictions not applied Source: https://www.quotaguard.com/docs/databases/postgresql/supabase-network-restrictions Example output from the get command when restrictions have never been applied. The allowed CIDR list is empty and restrictions were not applied successfully, meaning all addresses can connect. ```plaintext DB Allowed CIDRs: [] Restrictions applied successfully: false ``` -------------------------------- ### Start n8n with QGTunnel Source: https://www.quotaguard.com/docs/automation/n8n-integration Starts n8n with QGTunnel as the entrypoint, enabling SOCKS5 proxying for database connections. Use this command on a self-hosted n8n instance after configuring the tunnel. ```bash bin/qgtunnel n8n start ``` -------------------------------- ### Original Procfile Startup Command Source: https://www.quotaguard.com/docs/protocols/smtp/heroku-tunnel-setup Example of a Procfile before adding QGTunnel. Replace 'your-application your arguments' with your actual startup command. ```text web: your-application your arguments ``` -------------------------------- ### Configure Ruby SFTP with QuotaGuard HTTP proxy and list files Source: https://www.quotaguard.com/docs/outbound-proxy/ruby/sftp-file-transfer Use this example to route an SFTP transfer through QuotaGuard's static IP proxy. It reads proxy credentials from the QUOTAGUARDSTATIC_URL environment variable, creates an HTTP proxy, and then starts an SSH session to 1.1.1.1 as 'sftpuser'. The example then connects SFTP and iterates over the root directory, printing each entry's long name. The password 'sftppw' is shown as a placeholder; replace it with the actual password. ```ruby require 'net/ssh' require 'uri' require 'net/sftp' require 'net/ssh/proxy/http' quotaguard = URI(ENV["QUOTAGUARDSTATIC_URL"]) proxy = Net::SSH::Proxy::HTTP.new(quotaguard.host,quotaguard.port, :user => quotaguard.user,:password=>quotaguard.password) Net::SSH.start('1.1.1.1','sftpuser', {:port => 22, :proxy => proxy, :password => 'sftppw'}) do |ssh| ssh.sftp.connect do |sftp| sftp.dir.foreach("/") do |entry| puts entry.longname end end end ``` -------------------------------- ### Full database.yml example for MySQL via proxy Source: https://www.quotaguard.com/docs/platforms/heroku/static-setup Example database.yml with the connect_timeout key left empty to avoid connection hangs when using the SOCKS5 proxy. ```yaml common: &common adapter: mysql2 username: secureuser password: securepassword encoding: utf8 pool: 5 connect_timeout: development: <<: *common database: myapp_development test: <<: *common database: myapp_test production: <<: *common ``` -------------------------------- ### Prefix Procfile start command with bin/qgtunnel Source: https://www.quotaguard.com/docs/platforms/gigalixir/gigalixir-integration Gigalixir reads the Procfile to start the app. Prefixing with bin/qgtunnel starts the tunnel before the app. ```procfile web: bin/qgtunnel bin/my_app start ``` -------------------------------- ### Sample .qgtunnel configuration file Source: https://www.quotaguard.com/docs/qgtunnel/wildcard-hosts Example of the .qgtunnel file format that must be created for dynamic tunnels. The file should be named like qgtunnel.12345 and placed in the .qgtunnels directory. The example shows local port 12345, hostname, and database port 3306. ```ini [qgtunnel.12345] accept = "localhost:12345" connect = "hostname:3306" transparent = true ``` -------------------------------- ### Install QGTunnel in Dockerfile Source: https://www.quotaguard.com/docs/platforms/retool/retool-integration Add this line to your Dockerfile to install the QGTunnel binary. It downloads and extracts the latest qgtunnel tarball to /app/bin. ```dockerfile RUN curl https://s3.amazonaws.com/quotaguard/qgtunnel-latest.tar.gz | tar xz -C /app/bin ``` -------------------------------- ### Procfile: Prefix start command with QGTunnel Source: https://www.quotaguard.com/docs/platforms/scalingo/scalingo-integration Prefix the normal start command with bin/qgtunnel in the Procfile to route traffic through the tunnel. ```procfile web: bin/qgtunnel ``` -------------------------------- ### Update Procfile to Use QGTunnel Source: https://www.quotaguard.com/docs/databases/mariadb/direct-tunnel-setup Before and after examples of a Procfile startup command. Prepend 'bin/qgtunnel' to your existing startup command to route traffic through the tunnel. ```text web: your-application your arguments ``` ```text web: bin/qgtunnel your-application your arguments ``` -------------------------------- ### Original Heroku Procfile Source: https://www.quotaguard.com/docs/qgtunnel/vpn-tunneling-setup Example Procfile before modification, showing the original startup commands for web and worker processes. ```Procfile web: npm start worker: rails worker go ``` -------------------------------- ### Axios example for Netlify Function Source: https://www.quotaguard.com/docs/platforms/netlify/netlify-integration Use this Netlify Function (Node.js) to make proxied requests via QuotaGuard Static using Axios. Requires installing axios: `npm install axios`. The proxy URL is read from the `QUOTAGUARDSTATIC_URL` environment variable. ```JavaScript // netlify/functions/axios-example.mjs import axios from 'axios'; import { HttpsProxyAgent } from 'https-proxy-agent'; export default async (req, context) => { const proxyUrl = process.env.QUOTAGUARDSTATIC_URL; const agent = new HttpsProxyAgent(proxyUrl); try { const response = await axios.get('https://api.example.com/data', { httpsAgent: agent, headers: { 'Authorization': `Bearer ${process.env.API_KEY}` } }); return new Response(JSON.stringify(response.data), { headers: { 'Content-Type': 'application/json' } }); } catch (error) { return new Response( JSON.stringify({ error: error.message }), { status: 500, headers: { 'Content-Type': 'application/json' } } ); } }; ``` -------------------------------- ### Python: Install redis and PySocks Source: https://www.quotaguard.com/docs/databases/redis/redis-cloud-cidr-allow-list Install the required Python packages for using redis-py with a SOCKS5 proxy. ```bash pip install redis PySocks ``` -------------------------------- ### Ruby: Install redis and socksify Source: https://www.quotaguard.com/docs/databases/redis/redis-cloud-cidr-allow-list Install the required Ruby gems for using redis-rb with a SOCKS5 proxy. ```bash gem install redis socksify ``` -------------------------------- ### HTTP Proxy with Golang global configuration Source: https://www.quotaguard.com/docs/platforms/heroku/shield-setup Golang example for configuring the proxy for all requests by setting http.DefaultTransport. Uses the same proxy URL format as the per-request example. ```go proxyUrl, err := url.Parse("https://username:password@:9294") http.DefaultTransport = &http.Transport{Proxy: http.ProxyURL(proxyUrl)} ``` -------------------------------- ### Install PythonAnywhere dependencies Source: https://www.quotaguard.com/docs/outbound-proxy/python/pythonanywhere-setup Install the required Python packages from the requirements.txt file using pip. ```bash pip install -r requirements.txt ``` -------------------------------- ### Python with Requests: proxy setup and POST request Source: https://www.quotaguard.com/docs/platforms/emergent/emergent-integration Uses the requests library with the QUOTAGUARDSTATIC_URL environment variable to configure proxies for both HTTP and HTTPS. The call_protected_api function sends a JSON POST request through the proxy and returns the response JSON. Includes an example sync_inventory function for a partner API behind a corporate firewall. ```python import os import requests proxy_url = os.environ.get('QUOTAGUARDSTATIC_URL') proxies = { 'http': proxy_url, 'https': proxy_url } def call_protected_api(url, data): response = requests.post(url, json=data, proxies=proxies) return response.json() # Example: partner API behind corporate firewall def sync_inventory(inventory_data): return call_protected_api( 'https://api.partner.com/v2/inventory', inventory_data ) ``` -------------------------------- ### Run QGPass with Connection URL Source: https://www.quotaguard.com/docs/inbound-shield/testing-with-postman Starts QGPass with your QuotaGuard connection URL, keeping it alive for 100000 seconds. Replace {your connection url} with your actual URL. ```bash QUOTAGUARDSHIELD_URL={your connection url} ./bin/qgpass sleep 100000 ``` -------------------------------- ### Install PyMongo and PySocks for Python Source: https://www.quotaguard.com/docs/databases/mongodb/atlas-integration Install PyMongo and PySocks to enable SOCKS5 proxy support in Python MongoDB applications. ```bash pip install pymongo PySocks ``` -------------------------------- ### Set environment variable and start Netlify Dev Source: https://www.quotaguard.com/docs/platforms/netlify/netlify-integration Sets the QUOTAGUARDSTATIC_URL environment variable for the dev context and starts the local development server. Run these commands in your terminal before testing the function locally. ```bash # Set the environment variable locally netlify env:set QUOTAGUARDSTATIC_URL "http://username:password@:9293" --context dev # Start the local dev server netlify dev ``` -------------------------------- ### Install elasticsearch Python package Source: https://www.quotaguard.com/docs/apis/elastic-cloud/elastic-cloud-integration Install the elasticsearch-py package for Python. ```bash pip install elasticsearch ``` -------------------------------- ### Install QGTunnel in Application Image Source: https://www.quotaguard.com/docs/platforms/railway/railway-integration Download and extract QGTunnel into the application image. This package includes bin/qgtunnel and files for transparent mode. ```dockerfile RUN curl https://s3.amazonaws.com/quotaguard/qgtunnel-latest.tar.gz | tar xz -C /app ``` -------------------------------- ### Install socksjs for SOCKS5 proxy Source: https://www.quotaguard.com/docs/platforms/heroku/static-setup Install the socksjs module, recommended for SOCKS5 proxy support with authentication in Node.js. ```bash npm install socksjs ``` -------------------------------- ### Go Auto-Proxy Example Source: https://www.quotaguard.com/docs/platforms/kubernetes/kubernetes-integration Uses Go's net/http which automatically respects HTTP_PROXY/HTTPS_PROXY environment variables, so no explicit proxy configuration is needed. ```go package main import ( "fmt" "io" "net/http" ) func main() { // No explicit proxy configuration needed when HTTP_PROXY/HTTPS_PROXY are set resp, err := http.Get("https://api.example.com/data") if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Install @elastic/elasticsearch and https-proxy-agent Source: https://www.quotaguard.com/docs/apis/elastic-cloud/elastic-cloud-integration Install the required npm packages for the Node.js Elasticsearch client and the HTTPS proxy agent. ```bash npm install @elastic/elasticsearch https-proxy-agent ``` -------------------------------- ### QuotaGuard SOCKS5 proxy credentials example Source: https://www.quotaguard.com/docs/databases/postgresql/supabase-network-restrictions Shows the format of QuotaGuard SOCKS5 proxy credentials. Use the exact host and credentials from your QuotaGuard dashboard; do not assemble the hostname manually. The example host is us-east-static-01.quotaguard.com. ```text Host: -static-01.quotaguard.com Port: 1080 Username: your-username Password: your-password ``` -------------------------------- ### QuotaGuard Connection URL example Source: https://www.quotaguard.com/docs/platforms/static-ip-no-http-proxy Example Connection URL to set as QUOTAGUARDSTATIC_URL on the relay. The region host is taken from your dashboard. ```text http://username:password@us-east-static-01.quotaguard.com:9293 ``` -------------------------------- ### Check QGTunnel logs Source: https://www.quotaguard.com/docs/platforms/gigalixir/gigalixir-integration After enabling debug logging, run this command to view QGTunnel-related log entries. Use it to diagnose why QGTunnel is not starting. ```bash gigalixir logs | grep qgtunnel ``` -------------------------------- ### Original HTTPS URL Source: https://www.quotaguard.com/docs/protocols/https-tunneling/direct-tunnel-setup Example URL before QGTunnel is used. Replace with the new URL that includes the local port 4443. ```text https://hostname.for.your.server.com/some/long/path?var=1&var2=3 ``` -------------------------------- ### Install https-proxy-agent and Commit Source: https://www.quotaguard.com/docs/platforms/netlify/netlify-integration Install the https-proxy-agent package as a production dependency and commit the package files to your repository. This resolves the 'Module Not Found: https-proxy-agent' error. ```bash npm install https-proxy-agent --save git add package.json package-lock.json git commit -m "Add https-proxy-agent for QuotaGuard proxy" ``` -------------------------------- ### List subscriptions with curl Source: https://www.quotaguard.com/docs/account/usage-api/getting-started Quick example to list your subscriptions. Uses a Bearer token and returns a JSON array of subscription objects. ```bash $ curl -H "Authorization: Bearer qg_live_..." https://dash.quotaguard.com/api/v1/subscriptions ``` ```json { "subscriptions": [ { "id": "fksexz1b7td8xv", "app_name": "my-heroku-app", "plan": "static_enterprise", "plan_display": "Static: Enterprise", "status": "active", "platform": "heroku", "created_at": "2024-06-15T10:30:00Z" } ] } ``` -------------------------------- ### Original HTTPS URL Source: https://www.quotaguard.com/docs/outbound-proxy/https-setup Example of the original HTTPS URL before using QGTunnel. ```text https ://hostname.for.your.server.com/some/long/path?var=1&var2=3 ``` -------------------------------- ### Procfile Before Modification Source: https://www.quotaguard.com/docs/databases/mongodb/connect-via-static-ip Original Procfile command before adding QGTunnel. This is the 'before' state for Heroku users, showing the standard application start command. ```text web: your-application your arguments ``` -------------------------------- ### Run application under QGTunnel (local/generic, Heroku, Render, Railway, Fly.io, Docker, Kubernetes) Source: https://www.quotaguard.com/docs/databases/redis/redis-cloud-cidr-allow-list Shows how to launch your app under QGTunnel on various platforms. Each example uses 'bin/qgtunnel' as the entrypoint. For Heroku, the Procfile uses two lines for web and worker processes. For Docker and Kubernetes, the container spec must have qgtunnel as the entrypoint. ```bash bin/qgtunnel node server.js ``` ```text web: bin/qgtunnel node server.js worker: bin/qgtunnel node worker.js ``` ```text bin/qgtunnel npm start ``` ```text bin/qgtunnel npm start ``` ```text [processes] app = "bin/qgtunnel npm start" ``` ```dockerfile ENTRYPOINT ["/app/bin/qgtunnel"] CMD ["node", "server.js"] ``` ```yaml command: ["/app/bin/qgtunnel"] args: ["node", "server.js"] ``` -------------------------------- ### Go HTTP client with proxy Source: https://www.quotaguard.com/docs/platforms/gigalixir/gigalixir-integration Creates an HTTP client with a proxy from the QUOTAGUARDSTATIC_URL environment variable and makes a GET request. ```go proxyURL, _ := url.Parse(os.Getenv("QUOTAGUARDSTATIC_URL")) client := &http.Client{ Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}, } resp, _ := client.Get("https://api.example.com/data") defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) ``` -------------------------------- ### Install https-proxy-agent with npm Source: https://www.quotaguard.com/docs/platforms/netlify/netlify-integration Adds the https-proxy-agent package to your project, required for routing fetch requests through the QuotaGuard proxy in Netlify Functions. ```bash npm install https-proxy-agent ``` -------------------------------- ### Install https-proxy-agent with yarn Source: https://www.quotaguard.com/docs/platforms/netlify/netlify-integration Alternative to npm for adding the https-proxy-agent package to your project. ```bash yarn add https-proxy-agent ``` -------------------------------- ### Test proxy with curl Source: https://www.quotaguard.com/docs/outbound-proxy/dynamic-ip-geocoding/php-guide Test the proxy setup using curl with the -x flag and the QuotaGuard proxy URL. ```bash $ curl -x username:password@proxy.quotaguard.com:9292 http://www.google.com/ ``` -------------------------------- ### Node.js Explicit Proxy Configuration with https-proxy-agent Source: https://www.quotaguard.com/docs/platforms/kubernetes/kubernetes-integration Node.js does not automatically respect proxy environment variables. This example shows explicit configuration using the https-proxy-agent package. Install the agent with `npm install https-proxy-agent`. ```javascript 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)) .catch(error => console.error(error)); ``` -------------------------------- ### Download qgtunnel and force-add libnss_wrapper.so Source: https://www.quotaguard.com/docs/troubleshooting/nss-wrapper-missing-so-file Commands to download and extract qgtunnel into the project root, then force-add the missing .so file to Git because Git skips .so files by default. ```bash curl https://s3.amazonaws.com/quotaguard/qgtunnel-latest.tar.gz | tar xz ``` ```bash git add -f vendor/nss_wrapper/libnss_wrapper.so ``` -------------------------------- ### Elixir Finch with QuotaGuard Proxy Source: https://www.quotaguard.com/docs/platforms/fly-io/fly-io-integration Configures Finch with the QuotaGuard proxy by starting a Finch pool with proxy connection options and proxy authorization headers. The example includes starting the pool and making a request. ```elixir # In your application supervision tree proxy_url = System.get_env("QUOTAGUARDSTATIC_URL") uri = URI.parse(proxy_url) [username, password] = String.split(uri.userinfo, ":") Finch.start_link( name: MyFinch, pools: %{ :default => [ conn_opts: [ proxy: {:http, uri.host, uri.port, []}, proxy_headers: [ {"proxy-authorization", "Basic " <> Base.encode64("#{username}:#{password}")} ] ] ] } ) # Making a request Finch.build(:get, "https://api.example.com/data") |> Finch.request(MyFinch) ``` -------------------------------- ### Docker Configuration with QGTunnel Source: https://www.quotaguard.com/docs/databases/mongodb/atlas-integration Dockerfile instructions to run the application with QGTunnel as the entrypoint. ```dockerfile ENTRYPOINT ["/app/bin/qgtunnel"] CMD ["node", "server.js"] ``` -------------------------------- ### Updated HTTPS URL with QGTunnel Port Source: https://www.quotaguard.com/docs/protocols/https-tunneling/direct-tunnel-setup Example URL after QGTunnel setup. The port 4443 is added to route traffic through the tunnel. ```text https://hostname.for.your.server.com:4443/some/long/path?var=1&var2=3 ``` -------------------------------- ### Enable QGTunnel debug logging Source: https://www.quotaguard.com/docs/platforms/gigalixir/gigalixir-integration Set the QGTUNNEL_DEBUG environment variable to "true" to enable debug logging for QGTunnel. This is the first step when QGTunnel is not starting. ```bash gigalixir config:set QGTUNNEL_DEBUG="true" ``` -------------------------------- ### Node.js Explicit Proxy Configuration with undici Source: https://www.quotaguard.com/docs/platforms/kubernetes/kubernetes-integration Alternative Node.js example using the undici library's ProxyAgent and fetch. Requires the undici package and uses the QUOTAGUARDSTATIC_URL environment variable. ```javascript 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(); console.log(data); ``` -------------------------------- ### Make proxied HTTP request in Scala with sttp Source: https://www.quotaguard.com/docs/platforms/emergent/emergent-integration Scala example using sttp client to make a synchronous HTTP GET through a proxy from the QUOTAGUARDSTATIC_URL environment variable. It sets a default Authenticator with credentials from the URL's userInfo and configures the backend with httpProxy options. ```scala import sttp.client3._ import sttp.client3.httpclient.HttpClientSyncBackend import java.net.{InetSocketAddress, PasswordAuthentication, Proxy, Authenticator} object ProxiedClient { def call(url: String): String = { val proxyUrl = new java.net.URL(sys.env("QUOTAGUARDSTATIC_URL")) val userInfo = proxyUrl.getUserInfo.split(":") Authenticator.setDefault(new Authenticator { override def getPasswordAuthentication: PasswordAuthentication = new PasswordAuthentication(userInfo(0), userInfo(1).toCharArray) }) val backend = HttpClientSyncBackend( options = SttpBackendOptions.httpProxy(proxyUrl.getHost, proxyUrl.getPort) ) val request = basicRequest.get(uri"$url") val response = request.send(backend) response.body.getOrElse("") } } ``` -------------------------------- ### Configure Python PostgreSQL client with SOCKS5 Source: https://www.quotaguard.com/docs/platforms/koyeb/koyeb-integration Configures psycopg2 to use the SOCKS5 proxy from environment variables. Requires PySocks and psycopg2-binary installed via pip. ```python 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' ) ``` -------------------------------- ### Download QGTunnel into release overlay Source: https://www.quotaguard.com/docs/platforms/gigalixir/gigalixir-integration Creates the overlay directory and downloads QGTunnel into it so the tunnel binary ships inside the container. ```bash mkdir -p rel/overlays/bin curl https://s3.amazonaws.com/quotaguard/qgtunnel-latest.tar.gz | tar xz -C rel/overlays ``` -------------------------------- ### Set CC_RUN_COMMAND with QGTunnel Source: https://www.quotaguard.com/docs/platforms/clever-cloud/clever-cloud-integration Sets the CC_RUN_COMMAND environment variable to prefix the normal start command with bin/qgtunnel. Only one command is allowed; chain with ; or && for multiple commands. No effect on Docker. ```bash clever env set CC_RUN_COMMAND "bin/qgtunnel " ``` -------------------------------- ### Access HTTPS API with Node.js Request module Source: https://www.quotaguard.com/docs/platforms/heroku/static-setup Accesses an HTTPS API through the proxy using the Request module (npm install request). The standard Node.js HTTPS module does not handle proxy requests well, so this example uses the request library with the proxy option set to QUOTAGUARDSTATIC_URL. ```javascript var request = require('request'); var options = { proxy: process.env.QUOTAGUARDSTATIC_URL, url: 'https://api.github.com/repos/joyent/node', headers: { 'User-Agent': 'node.js' } }; function callback(error, response, body) { if (!error && response.statusCode == 200) { console.log(body); } } request(options, callback); ``` -------------------------------- ### Direct PHP cURL proxied POST request with JSON body Source: https://www.quotaguard.com/docs/platforms/pantheon/pantheon-integration Sends a POST request with a JSON body through the QuotaGuard proxy using cURL. Sets Content-Type and Accept headers to application/json, uses the same proxy credentials and timeouts as the GET example, and throws an Exception on cURL errors. ```php '; $proxy_port = 9293; $proxy_user = 'your-quotaguard-username'; $proxy_pass = 'your-quotaguard-password'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Accept: application/json' )); curl_setopt($ch, CURLOPT_PROXY, $proxy_host . ':' . $proxy_port); curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_user . ':' . $proxy_pass); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $response = curl_exec($ch); if (curl_errno($ch)) { $error = curl_error($ch); curl_close($ch); throw new Exception('cURL error: ' . $error); } curl_close($ch); return $response; } ``` -------------------------------- ### Direct PHP cURL proxied GET request Source: https://www.quotaguard.com/docs/platforms/pantheon/pantheon-integration Use for custom PHP code that doesn't use WordPress or Drupal's HTTP clients. Configures cURL with QuotaGuard proxy credentials and recommended timeouts, throws an Exception on cURL errors, and includes an example usage with error logging. ```php '; $proxy_port = 9293; $proxy_user = 'your-quotaguard-username'; $proxy_pass = 'your-quotaguard-password'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_PROXY, $proxy_host . ':' . $proxy_port); curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_user . ':' . $proxy_pass); // Recommended timeout settings curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $response = curl_exec($ch); if (curl_errno($ch)) { $error = curl_error($ch); curl_close($ch); throw new Exception('cURL error: ' . $error); } curl_close($ch); return $response; } // Example usage try { $result = make_proxied_request('https://api.example.com/data'); $data = json_decode($result, true); } catch (Exception $e) { error_log('Request failed: ' . $e->getMessage()); } ``` -------------------------------- ### Run Application Under QGTunnel - Fly.io fly.toml Source: https://www.quotaguard.com/docs/databases/postgresql/supabase-network-restrictions Fly.io configuration in fly.toml to run the application under QGTunnel. ```toml [processes] app = "bin/qgtunnel npm start" ``` -------------------------------- ### Create PEM bundle from key and certificate Source: https://www.quotaguard.com/docs/platforms/heroku/static-setup Create a PEM bundle containing the private key and certificate for use with stunnel. ```bash $ cat example.com.key example.com.cer > example.com.pem ``` -------------------------------- ### Python: confirm source IP with inet_client_addr() Source: https://www.quotaguard.com/docs/databases/postgresql/neon-ip-allow Python example that runs the same source-IP check using a database cursor. The printed value should match one of the two addresses in your QuotaGuard dashboard. ```python cur.execute("select inet_client_addr()") print("Neon sees this source IP:", cur.fetchone()[0]) ``` -------------------------------- ### Go with net/http Source: https://www.quotaguard.com/docs/platforms/replit/replit-integration Creates an HTTP client with a proxy from the QUOTAGUARDSTATIC_URL environment variable. Uses net/http and net/url packages. ```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) } ``` -------------------------------- ### Run App with QGTunnel Source: https://www.quotaguard.com/docs/platforms/emergent/emergent-integration Runs your application with QGTunnel, which creates local port mappings that route traffic through QuotaGuard's SOCKS5 proxy transparently. Requires downloading QGTunnel and the .qgtunnel configuration file from the dashboard. ```bash bin/qgtunnel your-app-command ``` -------------------------------- ### Create QGTunnel ConfigMap (kubectl create configmap) Source: https://www.quotaguard.com/docs/platforms/kubernetes/kubernetes-integration Creates a ConfigMap named 'qgtunnel-config' from the downloaded .qgtunnel configuration file. Run this after downloading the configuration from the QuotaGuard dashboard. ```bash kubectl create configmap qgtunnel-config \ --from-file=.qgtunnel \ -n your-namespace ``` -------------------------------- ### Quick Test Pod with kubectl run Source: https://www.quotaguard.com/docs/platforms/kubernetes/kubernetes-integration Runs a temporary curl pod to verify the proxy configuration by requesting ip.quotaguard.com. Replace the proxy host and credentials with your QuotaGuard static proxy details. ```bash kubectl run test-proxy --rm -it --restart=Never \ --env="HTTP_PROXY=http://username:password@:9293" \ --env="HTTPS_PROXY=http://username:password@:9293" \ --image=curlimages/curl -- \ curl -s https://ip.quotaguard.com ``` -------------------------------- ### Dockerfile with QGTunnel Source: https://www.quotaguard.com/docs/platforms/fly-io/fly-io-integration Modify your Dockerfile to include QGTunnel. Copies the binary and vendor directory, makes it executable, and sets it as the entrypoint. The CMD runs your Node.js application. ```dockerfile FROM node:18-slim WORKDIR /app # Copy application files COPY package*.json ./ RUN npm install COPY . . # Copy QGTunnel COPY bin/qgtunnel /app/bin/qgtunnel COPY vendor /app/vendor # Make qgtunnel executable RUN chmod +x /app/bin/qgtunnel # Use qgtunnel as entrypoint ENTRYPOINT ["/app/bin/qgtunnel"] CMD ["node", "server.js"] ``` -------------------------------- ### Run Application with QGTunnel (Development) Source: https://www.quotaguard.com/docs/databases/mongodb/atlas-integration Runs the application with QGTunnel in development. QGTunnel wraps the node process and handles proxying. ```bash bin/qgtunnel node server.js ``` -------------------------------- ### Launch script for environment-specific .qgtunnel Source: https://www.quotaguard.com/docs/qgtunnel/environment-specific-config Launch script that copies the appropriate .qgtunnel file based on the ENVIRONMENT variable, then runs bin/qgtunnel. Save as bin/qglaunch and call it instead of bin/qgtunnel. ```bash #!/bin/bash if [ "$ENVIRONMENT" == "staging" ]; then cp .qgtunnel.staging .qgtunnel else cp .qgtunnel.production .qgtunnel fi bin/qgtunnel $@ ``` -------------------------------- ### Install SOCKS proxy agent for Node.js Source: https://www.quotaguard.com/docs/databases/mongodb/atlas-integration Install the socks-proxy-agent package to enable SOCKS5 proxy support in Node.js applications. ```bash npm install socks-proxy-agent ``` -------------------------------- ### Download QGPass for Linux and Mac Source: https://www.quotaguard.com/docs/platforms/heroku/shield-setup Download and extract the qgpass binary for Linux or Mac (Mac only for local testing). Place the binary in the root directory of your app. ```bash $ curl https://s3.amazonaws.com/quotaguard/qgpass-latest.tar.gz | tar xz ``` ```bash $ curl https://quotaguard.s3.amazonaws.com/qgpass-1.1.0-darwin.tar.gz | tar xz ``` -------------------------------- ### Node.js axios with https-proxy-agent Source: https://www.quotaguard.com/docs/platforms/fly-io/fly-io-integration Uses axios with the https-proxy-agent to route requests through the QuotaGuard proxy. Requires installing the proxy agent with `npm install https-proxy-agent`. ```javascript 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)) .catch(error => console.error(error)); ``` -------------------------------- ### Cargo.toml Dependencies for reqwest Example Source: https://www.quotaguard.com/docs/platforms/fly-io/fly-io-integration Adds the required dependencies to Cargo.toml for the Rust reqwest example: reqwest with the json feature and tokio with the full feature. ```toml [dependencies] reqwest = { version = "0.11", features = ["json"] } tokio = { version = "1", features = ["full"] } ``` -------------------------------- ### Relay Endpoint URL Example Source: https://www.quotaguard.com/docs/platforms/glide-integration Example endpoint URL for the relay function. Set this as the Endpoint in Glide's Call API action or column. ```text https://abc123.lambda-url.us-east-1.on.aws/ ``` -------------------------------- ### Node.js axios proxy with https-proxy-agent Source: https://www.quotaguard.com/docs/platforms/koyeb/koyeb-integration Uses the https-proxy-agent package to route axios requests through the QuotaGuard proxy. Requires installing the dependency with 'npm install https-proxy-agent'. ```javascript 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)); ``` -------------------------------- ### QGTunnel: Configuration Not Found Source: https://www.quotaguard.com/docs/databases/mongodb/atlas-integration Error message indicating that the QGTunnel configuration file is missing. ```text qgtunnel: error: configuration file not found ``` -------------------------------- ### Download QGTunnel Source: https://www.quotaguard.com/docs/databases/mariadb/direct-tunnel-setup Downloads and extracts the latest QGTunnel software to the root of your project. Run this before configuring the tunnel. ```bash curl https://s3.amazonaws.com/quotaguard/qgtunnel-latest.tar.gz | tar xz ``` -------------------------------- ### Download QGTunnel and Extract to Project Root Source: https://www.quotaguard.com/docs/protocols/smtp/heroku-tunnel-setup Downloads and extracts the QGTunnel binary into the current directory. Run this from the root of your Heroku project. ```bash curl https://s3.amazonaws.com/quotaguard/qgtunnel-latest.tar.gz | tar xz ``` -------------------------------- ### Python requests auto-proxy example Source: https://www.quotaguard.com/docs/platforms/kubernetes/kubernetes-integration Python example using the requests library, which automatically respects HTTP_PROXY and HTTPS_PROXY environment variables. No explicit proxy configuration needed. ```python import requests # No explicit proxy configuration needed when HTTP_PROXY/HTTPS_PROXY are set response = requests.get('https://api.example.com/data') print(response.json()) ``` -------------------------------- ### Download QGTunnel with curl Source: https://www.quotaguard.com/docs/databases/postgresql/connect-via-static-ip Downloads and extracts the QGTunnel package into the current directory. Run this from the root directory of your application. ```bash $ curl https://s3.amazonaws.com/quotaguard/qgtunnel-latest.tar.gz | tar xz ``` -------------------------------- ### Set Secrets and Start Local Server Source: https://www.quotaguard.com/docs/platforms/supabase/edge-functions-integration Set the QUOTAGUARDSTATIC_URL secret locally and start the Supabase functions server for local development. This allows testing your function locally before deploying. ```bash # Set secret for local development supabase secrets set QUOTAGUARDSTATIC_URL="http://username:password@-static-01.quotaguard.com:9293" --local # Start the functions server supabase functions serve ``` -------------------------------- ### Verify Environment Variables with netlify env:list Source: https://www.quotaguard.com/docs/platforms/netlify/netlify-integration Run this command to list environment variables and verify that the proxy credentials are set correctly for the 407 Proxy Authentication Required troubleshooting step. ```bash netlify env:list ``` -------------------------------- ### Redis Cloud Endpoint and Port Example Source: https://www.quotaguard.com/docs/databases/redis/redis-cloud-cidr-allow-list Example of a Redis Cloud endpoint and port. The port is generally not 6379 and must be copied exactly from the database's Configuration screen. ```text redis-12345.c1.us-east-1-2.ec2.redns.redis-cloud.com:12345 ``` -------------------------------- ### Basic GET Request with HttpsProxyAgent Source: https://www.quotaguard.com/docs/platforms/netlify/netlify-integration Use this Netlify Function to make a GET request through the QuotaGuard Static proxy. It reads the proxy URL from the QUOTAGUARDSTATIC_URL environment variable and returns a 500 error if it is not configured. ```JavaScript // netlify/functions/api-call.mjs import { HttpsProxyAgent } from 'https-proxy-agent'; export default async (req, context) => { const proxyUrl = process.env.QUOTAGUARDSTATIC_URL; if (!proxyUrl) { return new Response( JSON.stringify({ error: 'Proxy URL not configured' }), { status: 500, headers: { 'Content-Type': 'application/json' } } ); } const agent = new HttpsProxyAgent(proxyUrl); try { const response = await fetch('https://api.example.com/data', { agent: agent }); const data = await response.json(); return new Response(JSON.stringify(data), { headers: { 'Content-Type': 'application/json' } }); } catch (error) { return new Response( JSON.stringify({ error: error.message }), { status: 500, headers: { 'Content-Type': 'application/json' } } ); } }; ``` -------------------------------- ### HTTP GET Request with Proxy Source: https://www.quotaguard.com/docs/automation/zapier-integration Use in a Zapier Code step to perform a GET request through the QuotaGuard proxy. Requires an input variable 'proxy_url' containing the proxy URL. Returns status code and JSON data. ```python import requests # Get proxy URL from Input Data proxy_url = input_data.get('proxy_url') # Configure proxy proxies = { 'http': proxy_url, 'https': proxy_url } # Make the request response = requests.get( 'https://api.example.com/data', proxies=proxies, timeout=25 ) # Return the response output = { 'status_code': response.status_code, 'data': response.json() } ``` -------------------------------- ### HTTPS Proxy with Java Source: https://www.quotaguard.com/docs/platforms/heroku/shield-setup Java example using Apache HttpClient (though the configuration applies to other JVM clients). It reads the QUOTAGUARDSHIELD_URL environment variable, sets system proxy properties, and uses an Authenticator for basic authentication. ```java import java.net.*; import java.io.*; public class HelloWorld { public static void main(String []args) throws IOException { URL proxyUrl = new URL(System.getenv("QUOTAGUARDSHIELD_URL")); String userInfo = proxyUrl.getUserInfo(); String user = userInfo.substring(0, userInfo.indexOf(':')); String password = userInfo.substring(userInfo.indexOf(':') + 1); URLConnection conn = null; System.setProperty("http.proxyHost", proxyUrl.getHost()); System.setProperty("http.proxyPort", Integer.toString(proxyUrl.getPort())); Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(user, password.toCharArray()); } }); URL url = new URL("https://ip.quotaguard.com"); conn = url.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } } ``` -------------------------------- ### Node.js HTTPS proxy with Request and https-proxy-agent Source: https://www.quotaguard.com/docs/platforms/heroku/shield-setup Use Node.js with the Request module and https-proxy-agent to make HTTPS requests through the proxy. Requires npm install request and npm install https-proxy-agent. The proxy URL is read from the QUOTAGUARDSHIELD_URL environment variable. ```javascript 'use strict'; require('dotenv').load({ silent: true }); var url = require('url'); var HttpsProxyAgent = require('https-proxy-agent'); var request = require('request'); var testEndpoint = 'https://ip.quotaguard.com'; var proxy = process.env.QUOTAGUARDSHIELD_URL; var agent = new HttpsProxyAgent(proxy); var options = { uri: url.parse(testEndpoint), agent }; function callback(error, response, body) { if (!error && response.statusCode == 200) { console.log('body: ', body); } else { console.log('error: ', error); } } request(options, callback); ``` -------------------------------- ### PHP (cURL) - Get Incident via Proxy with Environment Credentials Source: https://www.quotaguard.com/docs/apis/servicenow/servicenow-integration Uses curl to GET a single incident from the ServiceNow API endpoint, routing through the Quotaguard proxy from environment variable `QUOTAPROXY_URL, with HTTP basic credentials from `SNOW_USER` header ```PHP (cURL的语言 is not a language per schema but source heading says PHP (CURL) — using { // Get proxy URL from secrets const proxyUrl = Deno.env.get("QUOTAGUARDSTATIC_URL"); if (!proxyUrl) { return new Response( JSON.stringify({ error: "Proxy URL not configured" }), { status: 500, headers: { "Content-Type": "application/json" } } ); } // Parse proxy URL to extract credentials const url = new URL(proxyUrl); // Create HTTP client with proxy configuration const client = Deno.createHttpClient({ proxy: { url: `${url.protocol}//${url.host}`, basicAuth: { username: url.username, password: url.password, }, }, }); try { // Make the proxied request const response = await fetch("https://api.example.com/data", { client }); const data = await response.json(); return new Response( JSON.stringify(data), { headers: { "Content-Type": "application/json" } } ); } catch (error) { return new Response( JSON.stringify({ error: error.message }), { status: 500, headers: { "Content-Type": "application/json" } } ); } finally { // Always close the client when done client.close(); } }); ``` -------------------------------- ### Download QGSocksify with curl Source: https://www.quotaguard.com/docs/qgtunnel/vpn-tunneling-setup Downloads and extracts the latest QuotaGuard socksify tarball into the current project directory. ```bash curl https://quotaguard.s3.amazonaws.com/quotaguard-socksify-latest.tar.gz | tar xz ``` -------------------------------- ### Test Proxy with curl Source: https://www.quotaguard.com/docs/outbound-proxy/dynamic-ip-geocoding/ruby-guide Test the proxy setup using curl with the authenticated connection string. ```bash $ curl -x username:password@proxy.quotaguard.com:9292 http://www.google.com/ ``` -------------------------------- ### Modified HTTPS URL with QGTunnel Source: https://www.quotaguard.com/docs/outbound-proxy/https-setup Example of the modified HTTPS URL using the QGTunnel local port. ```text https://hostname.for.your.server.com:4443/some/long/path?var=1&var2=3 ``` -------------------------------- ### Procfile Before QGTunnel Source: https://www.quotaguard.com/docs/databases/mysql/django-setup Original Procfile entry before adding QGTunnel. ```text web: your-application your arguments ```