Skip to content

Upstream Proxy API ​

The Upstream Proxy API allows you to chain NectoProxy through another proxy server. This is useful in corporate networks where all internet access must go through a company proxy, or when you need to layer multiple proxy tools.

Endpoints Overview ​

MethodEndpointDescription
GET/api/upstream-proxyGet current configuration
PUT/api/upstream-proxyUpdate configuration
POST/api/upstream-proxy/enableEnable the upstream proxy
POST/api/upstream-proxy/disableDisable the upstream proxy
DELETE/api/upstream-proxyClear configuration

Get Current Configuration ​

GET /api/upstream-proxy

Retrieve the current upstream proxy configuration.

Example Request ​

bash
curl http://localhost:8889/api/upstream-proxy

Response 200 OK (configured) ​

json
{
  "config": {
    "enabled": true,
    "type": "http",
    "host": "corporate-proxy.example.com",
    "port": 3128,
    "auth": {
      "username": "user",
      "password": "pass"
    },
    "bypassRules": [
      "localhost",
      "127.0.0.1",
      "*.local"
    ]
  }
}

Response 200 OK (not configured) ​

json
{
  "config": null
}

Update Configuration ​

PUT /api/upstream-proxy

Set or update the upstream proxy configuration.

Request Body ​

json
{
  "enabled": true,
  "type": "http",
  "host": "proxy.example.com",
  "port": 8080,
  "auth": {
    "username": "user",
    "password": "password"
  },
  "bypassRules": [
    "localhost",
    "127.0.0.1",
    "*.local",
    "*.internal.company.com"
  ]
}
FieldTypeRequiredDescription
enabledbooleanNoWhether the upstream proxy is active. Default: false
typestringNoProxy protocol: http, https, socks4, or socks5. Default: "http"
hoststringYes*Proxy server hostname or IP. *Required when enabled is true
portnumberYes*Proxy server port. *Required when enabled is true
authobjectNoAuthentication credentials
auth.usernamestring-Username for proxy authentication
auth.passwordstring-Password for proxy authentication
bypassRulesstring[]NoPatterns for hosts that bypass the upstream proxy. Default: ["localhost", "127.0.0.1", "*.local"]

Example Request ​

bash
curl -X PUT http://localhost:8889/api/upstream-proxy \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "type": "http",
    "host": "proxy.corp.example.com",
    "port": 3128,
    "bypassRules": ["localhost", "127.0.0.1", "*.local", "10.*"]
  }'

Response 200 OK ​

json
{
  "config": {
    "enabled": true,
    "type": "http",
    "host": "proxy.corp.example.com",
    "port": 3128,
    "bypassRules": ["localhost", "127.0.0.1", "*.local", "10.*"]
  }
}

Error 400 Bad Request ​

json
{
  "error": "Host is required when proxy is enabled"
}
json
{
  "error": "Port is required when proxy is enabled"
}

Enable Upstream Proxy ​

POST /api/upstream-proxy/enable

Enable a previously configured upstream proxy without needing to resend the full configuration.

Example Request ​

bash
curl -X POST http://localhost:8889/api/upstream-proxy/enable

Response 200 OK ​

json
{
  "config": {
    "enabled": true,
    "type": "http",
    "host": "proxy.corp.example.com",
    "port": 3128,
    "bypassRules": ["localhost", "127.0.0.1", "*.local"]
  }
}

Error 400 Bad Request ​

json
{
  "error": "No proxy configured"
}

Prerequisites

You must configure the upstream proxy via PUT /api/upstream-proxy before calling this endpoint. If no proxy has been configured, the request will fail.


Disable Upstream Proxy ​

POST /api/upstream-proxy/disable

Disable the upstream proxy while preserving the configuration. The proxy can be re-enabled later without reconfiguration.

Example Request ​

bash
curl -X POST http://localhost:8889/api/upstream-proxy/disable

Response 200 OK ​

json
{
  "config": {
    "enabled": false,
    "type": "http",
    "host": "proxy.corp.example.com",
    "port": 3128,
    "bypassRules": ["localhost", "127.0.0.1", "*.local"]
  }
}

Clear Configuration ​

DELETE /api/upstream-proxy

Remove the upstream proxy configuration entirely. All traffic will go directly to the target servers.

Example Request ​

bash
curl -X DELETE http://localhost:8889/api/upstream-proxy

Response 200 OK ​

json
{
  "config": null
}

Supported Proxy Types ​

TypeDescription
httpStandard HTTP proxy (CONNECT method for HTTPS)
httpsHTTP proxy over TLS
socks4SOCKS4 proxy
socks5SOCKS5 proxy (supports authentication and DNS resolution)

Bypass Rules ​

Bypass rules define patterns for hostnames that should not be routed through the upstream proxy. Matching requests go directly to the target server.

PatternMatches
localhostExact match for localhost
127.0.0.1Exact match for 127.0.0.1
*.localAny hostname ending in .local
*.internal.corp.comAny subdomain of internal.corp.com
10.*Any hostname starting with 10.

Upstream Proxy Configuration Schema ​

Full UpstreamProxyConfig Schema
FieldTypeDescription
enabledbooleanWhether the proxy is active
typestringProtocol type: http, https, socks4, or socks5
hoststringProxy server hostname or IP address
portnumberProxy server port
authobject|undefinedOptional authentication credentials
auth.usernamestringAuthentication username
auth.passwordstringAuthentication password
bypassRulesstring[]Hostname patterns that bypass the upstream proxy

Example: Corporate Proxy with SOCKS5 ​

Configure SOCKS5 proxy with authentication
bash
curl -X PUT http://localhost:8889/api/upstream-proxy \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "type": "socks5",
    "host": "socks.corp.example.com",
    "port": 1080,
    "auth": {
      "username": "john.doe",
      "password": "secure-password"
    },
    "bypassRules": [
      "localhost",
      "127.0.0.1",
      "*.local",
      "*.corp.example.com",
      "10.*",
      "192.168.*"
    ]
  }'