Skip to main content

Proxy Configuration Guide

This document describes how to configure proxy settings for Cortex to be able to work behind your proxy.

Command Line Interface (CLI)​

Basic Usage


cortex config [OPTIONS] [COMMAND]

To display all current configurations


cortex config status

Example Output:


+-----------------------+------------------------+
| Config name | Value |
+-----------------------+------------------------+
| no_proxy | localhost,127.0.0.1 |
+-----------------------+------------------------+
| proxy_password | |
+-----------------------+------------------------+
| proxy_url | http://localhost:8080 |
+-----------------------+------------------------+
| proxy_username | |
+-----------------------+------------------------+
| verify_host_ssl | true |
+-----------------------+------------------------+
| verify_peer_ssl | false |
+-----------------------+------------------------+
| verify_proxy_host_ssl | true |
+-----------------------+------------------------+
| verify_proxy_ssl | true |
+-----------------------+------------------------+

Options​

OptionDescriptionExample
-h, --helpPrint help message and exit
--proxy_url <proxy_url>Set the proxy URLcortex config --proxy_url http://localhost:8080
--proxy_username <proxy_username>Set the username for proxycortex config --proxy_username my_username
--proxy_password <proxy_password>Set the password for proxycortex config --proxy_password my_password
--no_proxy <no_proxy>Set the no_proxy listcortex config --no_proxy localhost,127.0.0.1
--verify_proxy_ssl [on/off]Verify proxy SSLcortex config --verify_proxy_ssl on
--verify_proxy_host_ssl [on/off]Verify proxy host SSLcortex config --verify_proxy_host_ssl on
--verify_peer_ssl [on/off]Verify peer SSLcortex config --verify_peer_ssl off
--verify_host_ssl [on/off]Verify host SSLcortex config --verify_host_ssl on

Proxy API Configuration​

Endpoints​

To get the current configuration


GET /v1/configs

or


curl GET http://127.0.0.1:39281/v1/configs

Response


{
"allowed_origins": [
"http://localhost:39281",
"http://127.0.0.1:39281",
"http://0.0.0.0:39281"
],
"cors": true,
"no_proxy": "localhost,127.0.0.1",
"proxy_password": "",
"proxy_url": "http://localhost:8080",
"proxy_username": "",
"verify_host_ssl": true,
"verify_peer_ssl": false,
"verify_proxy_host_ssl": true,
"verify_proxy_ssl": true
}

To update the current configuration​

PATCH /v1/configs

Request Headers​

Content-Type: application/json

Request Body​

{
"no_proxy": "localhost",
"proxy_url": "http://localhost:8080",
"proxy_username": "my_username",
"proxy_password": "my_password",
"verify_host_ssl": false,
"verify_peer_ssl": false,
"verify_proxy_host_ssl": false,
"verify_proxy_ssl": false
}

Parameters​
FieldTypeDescription
no_proxystringList of origins which request do not need to go through a proxy. Comma separated value
proxy_urlstringProxy URL
proxy_usernamestringUsername for proxy authentication
proxy_passwordstringPassword for proxy authentication
verify_host_sslbooleanVerify host SSL
verify_peer_sslbooleanVerify peer SSL
verify_proxy_host_sslbooleanVerify proxy host SSL
verify_proxy_sslbooleanVerify proxy SSL
Response​

{
"config": {
"allowed_origins": [
"http://localhost:39281",
"http://127.0.0.1:39281",
"http://0.0.0.0:39281"
],
"cors": true,
"no_proxy": "localhost",
"proxy_password": "my_password",
"proxy_url": "http://localhost:8080",
"proxy_username": "my_username",
"verify_host_ssl": false,
"verify_peer_ssl": false,
"verify_proxy_host_ssl": false,
"verify_proxy_ssl": false
},
"message": "Configuration updated successfully"
}

Testing proxy configuration​

You can test your proxy configuration using mitmproxy. This guide is written on macOS, but you can use it on any other platform.

Install mitmproxy​


brew install mitmproxy

Start mitmproxy​


mitmproxy --set stream_large_bodies=1m

mitmproxy will start on port 8080. After mitmproxy has started, you can add different options by pressing the capital letter O and this will display an optional screen. As an example, try searching for proxyauth and hit enter when you find it. Then, type username:password and hit enter again. You will see your newly added option is red-colored.

Now we can use the Cortex CLI to tweak our config and use that proxy. In mitmproxy, press the capital letter E to see the event log. You will see the request and response logs in this screen.

Let's try changing our config in a different terminal window.


cortex config --proxy_url http://localhost:8080 --proxy_username username --proxy_password password


Configuration updated successfully!

Let's try to use a wrong authentication for your proxy.


cortex config --proxy_password wrong_pw

mproxy