Skip to content

PHP

You will first need your Proxy Credentials so make sure you can find them in the dashboard

Credentials

Making Proxied TCP Connections

Port Leases

If your software does not natively support SOCKS proxies, one option you have is to leverage Noble Port leases. For example if you wanted to connect to a MongoDB database:

php
<?php

use MongoDB\Client;
use GuzzleHttp\Client as GuzzleClient;

// Create a Guzzle HTTP client
$guzzleClient = new GuzzleClient();

// Make a POST request to obtain a lease from the API
$response = $guzzleClient->post('https://api.noble-ip.com/v1/leases', [
    'json' => [
        'target_host' => 'mongodb.mycompany.com',
        'target_port' => 27017,
        'proxy_token' => 'fp_PROXYTOKEN'
    ]
]);

// Get the lease details from the response
$lease = json_decode($response->getBody()->getContents());

// Construct the MongoDB connection string
$connectionString = "mongodb://{$lease->hostname}:{$lease->port}/";

// Connect to the MongoDB server
$client = new Client($connectionString);

// Access a specific database
$database = $client->selectDatabase('mydatabase');

?>

Making Proxied HTTP/HTTPs Requests

if you need to access a service over HTTP via a static IP, you can leverage the HTTPS proxies.

Then you can leverage a HTTP library like requests to make API calls:

php
<?php
use GuzzleHttp\Client;

// Create a Guzzle HTTP client with proxy configuration
$client = new Client();

// Make a GET request using the proxy
$response = $client->request('GET', 'https://example.com', [
    'proxy' => [
        'http'  => 'https://noble:fp_NOBLETOKEN@p-12345.noble-ip.com:3129',
        'https' => 'https://noble:fp_NOBLETOKEN@p-12345.noble-ip.com:3129'
    ]
]);

// Output the response body
echo $response->getBody();
?>