mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 08:42:13 +02:00
Compare commits
9 Commits
probe-prox
...
probe-prox
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d708fbbb52 | ||
|
|
03bceb959e | ||
|
|
efa411206e | ||
|
|
27fd99f2e8 | ||
|
|
07361bfeb7 | ||
|
|
bc8a5be0fa | ||
|
|
518768078a | ||
|
|
86e95f99ff | ||
|
|
ea48f56097 |
@@ -27,6 +27,33 @@ const CustomProbeDocumentation: FunctionComponent<ComponentProps> = (
|
||||
docker run --name oneuptime-probe --network host -e PROBE_KEY=${props.probeKey.toString()} -e PROBE_ID=${props.probeId.toString()} -e ONEUPTIME_URL=${host.toString()} -d oneuptime/probe:release
|
||||
`}
|
||||
/>
|
||||
<div className="mt-4">
|
||||
<h4 className="text-sm font-medium text-gray-700 mb-2">
|
||||
With Proxy Configuration (Optional)
|
||||
</h4>
|
||||
<CodeBlock
|
||||
language="bash"
|
||||
code={`
|
||||
# With HTTP/HTTPS proxy
|
||||
docker run --name oneuptime-probe --network host \\
|
||||
-e PROBE_KEY=${props.probeKey.toString()} \\
|
||||
-e PROBE_ID=${props.probeId.toString()} \\
|
||||
-e ONEUPTIME_URL=${host.toString()} \\
|
||||
-e HTTP_PROXY_URL=http://proxy.example.com:8080 \\
|
||||
-e HTTPS_PROXY_URL=http://proxy.example.com:8080 \\
|
||||
-d oneuptime/probe:release
|
||||
|
||||
# With proxy authentication
|
||||
docker run --name oneuptime-probe --network host \\
|
||||
-e PROBE_KEY=${props.probeKey.toString()} \\
|
||||
-e PROBE_ID=${props.probeId.toString()} \\
|
||||
-e ONEUPTIME_URL=${host.toString()} \\
|
||||
-e HTTP_PROXY_URL=http://username:password@proxy.example.com:8080 \\
|
||||
-e HTTPS_PROXY_URL=http://username:password@proxy.example.com:8080 \\
|
||||
-d oneuptime/probe:release
|
||||
`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -16,6 +16,37 @@ docker run --name oneuptime-probe --network host -e PROBE_KEY=<probe-key> -e PRO
|
||||
|
||||
If you are self hosting OneUptime, you can change `ONEUPTIME_URL` to your custom self hosted instance.
|
||||
|
||||
##### Proxy Configuration
|
||||
|
||||
If your probe needs to go through a proxy server to reach OneUptime or monitor external resources, you can configure proxy settings using these environment variables:
|
||||
|
||||
```
|
||||
# For HTTP proxy
|
||||
docker run --name oneuptime-probe --network host \
|
||||
-e PROBE_KEY=<probe-key> \
|
||||
-e PROBE_ID=<probe-id> \
|
||||
-e ONEUPTIME_URL=https://oneuptime.com \
|
||||
-e HTTP_PROXY_URL=http://proxy.example.com:8080 \
|
||||
-d oneuptime/probe:release
|
||||
|
||||
# For HTTPS proxy
|
||||
docker run --name oneuptime-probe --network host \
|
||||
-e PROBE_KEY=<probe-key> \
|
||||
-e PROBE_ID=<probe-id> \
|
||||
-e ONEUPTIME_URL=https://oneuptime.com \
|
||||
-e HTTPS_PROXY_URL=http://proxy.example.com:8080 \
|
||||
-d oneuptime/probe:release
|
||||
|
||||
# With proxy authentication
|
||||
docker run --name oneuptime-probe --network host \
|
||||
-e PROBE_KEY=<probe-key> \
|
||||
-e PROBE_ID=<probe-id> \
|
||||
-e ONEUPTIME_URL=https://oneuptime.com \
|
||||
-e HTTP_PROXY_URL=http://username:password@proxy.example.com:8080 \
|
||||
-e HTTPS_PROXY_URL=http://username:password@proxy.example.com:8080 \
|
||||
-d oneuptime/probe:release
|
||||
```
|
||||
|
||||
#### Docker Compose
|
||||
|
||||
You can also run the probe using docker-compose. Create a `docker-compose.yml` file with the following content:
|
||||
@@ -35,6 +66,31 @@ services:
|
||||
restart: always
|
||||
```
|
||||
|
||||
##### With Proxy Configuration
|
||||
|
||||
If you need to use a proxy server, you can add proxy environment variables:
|
||||
|
||||
```yaml
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
oneuptime-probe:
|
||||
image: oneuptime/probe:release
|
||||
container_name: oneuptime-probe
|
||||
environment:
|
||||
- PROBE_KEY=<probe-key>
|
||||
- PROBE_ID=<probe-id>
|
||||
- ONEUPTIME_URL=https://oneuptime.com
|
||||
# Proxy configuration (optional)
|
||||
- HTTP_PROXY_URL=http://proxy.example.com:8080
|
||||
- HTTPS_PROXY_URL=http://proxy.example.com:8080
|
||||
# For proxy with authentication:
|
||||
# - HTTP_PROXY_URL=http://username:password@proxy.example.com:8080
|
||||
# - HTTPS_PROXY_URL=http://username:password@proxy.example.com:8080
|
||||
network_mode: host
|
||||
restart: always
|
||||
```
|
||||
|
||||
Then run the following command:
|
||||
|
||||
```
|
||||
@@ -56,20 +112,61 @@ spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: oneuptime-probe
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: oneuptime-probe
|
||||
spec:
|
||||
containers:
|
||||
image: oneuptime/probe:release
|
||||
env:
|
||||
- name: PROBE_KEY
|
||||
value: "<probe-key>"
|
||||
- name: PROBE_ID
|
||||
value: "<probe-id>"
|
||||
- name: ONEUPTIME_URL
|
||||
value: "https://oneuptime.com"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: oneuptime-probe
|
||||
spec:
|
||||
containers:
|
||||
- name: oneuptime-probe
|
||||
image: oneuptime/probe:release
|
||||
env:
|
||||
- name: PROBE_KEY
|
||||
value: "<probe-key>"
|
||||
- name: PROBE_ID
|
||||
value: "<probe-id>"
|
||||
- name: ONEUPTIME_URL
|
||||
value: "https://oneuptime.com"
|
||||
```
|
||||
|
||||
##### With Proxy Configuration
|
||||
|
||||
If you need to use a proxy server, you can add proxy environment variables:
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: oneuptime-probe
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: oneuptime-probe
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: oneuptime-probe
|
||||
spec:
|
||||
containers:
|
||||
- name: oneuptime-probe
|
||||
image: oneuptime/probe:release
|
||||
env:
|
||||
- name: PROBE_KEY
|
||||
value: "<probe-key>"
|
||||
- name: PROBE_ID
|
||||
value: "<probe-id>"
|
||||
- name: ONEUPTIME_URL
|
||||
value: "https://oneuptime.com"
|
||||
# Proxy configuration (optional)
|
||||
- name: HTTP_PROXY_URL
|
||||
value: "http://proxy.example.com:8080"
|
||||
- name: HTTPS_PROXY_URL
|
||||
value: "http://proxy.example.com:8080"
|
||||
# For proxy with authentication, use:
|
||||
# - name: HTTP_PROXY_URL
|
||||
# value: "http://username:password@proxy.example.com:8080"
|
||||
# - name: HTTPS_PROXY_URL
|
||||
# value: "http://username:password@proxy.example.com:8080"
|
||||
```
|
||||
|
||||
Then run the following command:
|
||||
@@ -80,6 +177,46 @@ kubectl apply -f oneuptime-probe.yaml
|
||||
|
||||
If you are self hosting OneUptime, you can change `ONEUPTIME_URL` to your custom self hosted instance.
|
||||
|
||||
### Environment Variables
|
||||
|
||||
The probe supports the following environment variables:
|
||||
|
||||
#### Required Variables
|
||||
- `PROBE_KEY` - The probe key from your OneUptime dashboard
|
||||
- `PROBE_ID` - The probe ID from your OneUptime dashboard
|
||||
- `ONEUPTIME_URL` - The URL of your OneUptime instance (default: https://oneuptime.com)
|
||||
|
||||
#### Optional Variables
|
||||
- `HTTP_PROXY_URL` - HTTP proxy server URL for HTTP requests
|
||||
- `HTTPS_PROXY_URL` - HTTP proxy server URL for HTTPS requests
|
||||
- `PROBE_NAME` - Custom name for the probe
|
||||
- `PROBE_DESCRIPTION` - Description for the probe
|
||||
- `PROBE_MONITORING_WORKERS` - Number of monitoring workers (default: 1)
|
||||
- `PROBE_MONITOR_FETCH_LIMIT` - Number of monitors to fetch at once (default: 10)
|
||||
- `PROBE_MONITOR_RETRY_LIMIT` - Number of retries for failed monitors (default: 3)
|
||||
- `PROBE_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS` - Timeout for synthetic monitor scripts in milliseconds (default: 60000)
|
||||
- `PROBE_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS` - Timeout for custom code monitor scripts in milliseconds (default: 60000)
|
||||
|
||||
#### Proxy Configuration
|
||||
|
||||
The probe supports both HTTP and HTTPS proxy servers. When configured, the probe will route all monitoring traffic through the specified proxy servers.
|
||||
|
||||
**Proxy URL Format:**
|
||||
```
|
||||
http://[username:password@]proxy.server.com:port
|
||||
```
|
||||
|
||||
**Examples:**
|
||||
- Basic proxy: `http://proxy.example.com:8080`
|
||||
- With authentication: `http://username:password@proxy.example.com:8080`
|
||||
|
||||
**Supported Features:**
|
||||
- HTTP and HTTPS proxy support
|
||||
- Proxy authentication (username/password)
|
||||
- Automatic fallback between HTTP and HTTPS proxies
|
||||
- Works with all monitor types (Website, API, SSL, Synthetic, etc.)
|
||||
|
||||
**Note:** Both standard environment variables (`HTTP_PROXY_URL`, `HTTPS_PROXY_URL`) and lowercase variants (`http_proxy`, `https_proxy`) are supported for compatibility.
|
||||
|
||||
### Verify
|
||||
|
||||
|
||||
@@ -63,6 +63,31 @@
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
||||
<script>hljs.highlightAll();</script>
|
||||
|
||||
<style>
|
||||
/* Custom styles for code blocks in blog posts */
|
||||
.blog-body pre {
|
||||
font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', 'Courier New', monospace !important;
|
||||
font-size: 14px !important;
|
||||
line-height: 1.5 !important;
|
||||
font-weight: 400 !important;
|
||||
}
|
||||
|
||||
.blog-body pre code {
|
||||
font-family: inherit !important;
|
||||
font-size: inherit !important;
|
||||
line-height: inherit !important;
|
||||
font-weight: inherit !important;
|
||||
}
|
||||
|
||||
/* Ensure highlight.js doesn't override our font settings */
|
||||
.blog-body .hljs {
|
||||
font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', 'Courier New', monospace !important;
|
||||
font-size: 14px !important;
|
||||
line-height: 1.5 !important;
|
||||
font-weight: 400 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
@@ -84,3 +84,16 @@ export const PROBE_MONITOR_RETRY_LIMIT: number = process.env[
|
||||
export const PORT: Port = new Port(
|
||||
process.env["PORT"] ? parseInt(process.env["PORT"]) : 3874,
|
||||
);
|
||||
|
||||
// Proxy configuration for all HTTP/HTTPS requests made by the probe
|
||||
// HTTP_PROXY_URL: Proxy for HTTP requests
|
||||
// Format: http://[username:password@]proxy.example.com:port
|
||||
// Example: http://proxy.example.com:8080
|
||||
// Example with auth: http://user:pass@proxy.example.com:8080
|
||||
export const HTTP_PROXY_URL: string | null = process.env["HTTP_PROXY_URL"] || process.env["http_proxy"] || null;
|
||||
|
||||
// HTTPS_PROXY_URL: Proxy for HTTPS requests
|
||||
// Format: http://[username:password@]proxy.example.com:port
|
||||
// Example: http://proxy.example.com:8080
|
||||
// Example with auth: http://user:pass@proxy.example.com:8080
|
||||
export const HTTPS_PROXY_URL: string | null = process.env["HTTPS_PROXY_URL"] || process.env["https_proxy"] || null;
|
||||
|
||||
@@ -11,6 +11,7 @@ import FetchMonitorList from "./Jobs/Monitor/FetchList";
|
||||
import FetchMonitorTestList from "./Jobs/Monitor/FetchMonitorTest";
|
||||
import Register from "./Services/Register";
|
||||
import MetricsAPI from "./API/Metrics";
|
||||
import ProxyConfig from "./Utils/ProxyConfig";
|
||||
import { PromiseVoidFunction } from "Common/Types/FunctionTypes";
|
||||
import logger from "Common/Server/Utils/Logger";
|
||||
import App from "Common/Server/Utils/StartServer";
|
||||
@@ -22,6 +23,27 @@ const APP_NAME: string = "probe";
|
||||
|
||||
const init: PromiseVoidFunction = async (): Promise<void> => {
|
||||
try {
|
||||
// Initialize proxy configuration first, before any HTTP requests
|
||||
ProxyConfig.configure();
|
||||
|
||||
// Log proxy status
|
||||
if (ProxyConfig.isProxyConfigured()) {
|
||||
logger.info("Proxy configuration:");
|
||||
|
||||
const httpProxy = ProxyConfig.getHttpProxyUrl();
|
||||
const httpsProxy = ProxyConfig.getHttpsProxyUrl();
|
||||
|
||||
if (httpProxy) {
|
||||
logger.info(` HTTP proxy: ${httpProxy}`);
|
||||
}
|
||||
|
||||
if (httpsProxy) {
|
||||
logger.info(` HTTPS proxy: ${httpsProxy}`);
|
||||
}
|
||||
|
||||
logger.info("Proxy will be used for all HTTP/HTTPS requests");
|
||||
}
|
||||
|
||||
// Initialize telemetry
|
||||
Telemetry.init({
|
||||
serviceName: APP_NAME,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { PROBE_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS } from "../../../Config";
|
||||
import ProxyConfig from "../../ProxyConfig";
|
||||
import ReturnResult from "Common/Types/IsolatedVM/ReturnResult";
|
||||
import CustomCodeMonitorResponse from "Common/Types/Monitor/CustomCodeMonitor/CustomCodeMonitorResponse";
|
||||
import ObjectID from "Common/Types/ObjectID";
|
||||
@@ -35,6 +36,13 @@ export default class CustomCodeMonitor {
|
||||
try {
|
||||
const startTime: [number, number] = process.hrtime();
|
||||
|
||||
// Log proxy status for custom code monitoring
|
||||
if (ProxyConfig.isProxyConfigured()) {
|
||||
logger.debug(
|
||||
`Custom Code Monitor - HTTP proxy: ${ProxyConfig.getHttpProxyUrl()}, HTTPS proxy: ${ProxyConfig.getHttpsProxyUrl()}`,
|
||||
);
|
||||
}
|
||||
|
||||
result = await VMRunner.runCodeInSandbox({
|
||||
code: options.script,
|
||||
options: {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import OnlineCheck from "../../OnlineCheck";
|
||||
import ProxyConfig from "../../ProxyConfig";
|
||||
import URL from "Common/Types/API/URL";
|
||||
import OneUptimeDate from "Common/Types/Date";
|
||||
import BadDataException from "Common/Types/Exception/BadDataException";
|
||||
@@ -264,7 +265,7 @@ export default class SSLMonitor {
|
||||
port: number,
|
||||
rejectUnauthorized: boolean,
|
||||
): RequestOptions {
|
||||
return {
|
||||
const options: RequestOptions = {
|
||||
hostname: url,
|
||||
agent: false,
|
||||
rejectUnauthorized: rejectUnauthorized,
|
||||
@@ -272,5 +273,28 @@ export default class SSLMonitor {
|
||||
port,
|
||||
protocol: "https:",
|
||||
};
|
||||
|
||||
// Use proxy agent if proxy is configured
|
||||
if (ProxyConfig.isProxyConfigured()) {
|
||||
const httpsProxyAgent = ProxyConfig.getHttpsProxyAgent();
|
||||
const httpProxyAgent = ProxyConfig.getHttpProxyAgent();
|
||||
|
||||
// Prefer HTTPS proxy agent, fall back to HTTP proxy agent
|
||||
const proxyAgent = httpsProxyAgent || httpProxyAgent;
|
||||
|
||||
if (proxyAgent) {
|
||||
options.agent = proxyAgent;
|
||||
|
||||
const httpsProxyUrl = ProxyConfig.getHttpsProxyUrl();
|
||||
const httpProxyUrl = ProxyConfig.getHttpProxyUrl();
|
||||
const proxyUrl = httpsProxyUrl || httpProxyUrl;
|
||||
|
||||
logger.debug(
|
||||
`SSL Monitor using proxy: ${proxyUrl} (HTTPS: ${!!httpsProxyUrl}, HTTP: ${!!httpProxyUrl})`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { PROBE_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS } from "../../../Config";
|
||||
import ProxyConfig from "../../ProxyConfig";
|
||||
import BadDataException from "Common/Types/Exception/BadDataException";
|
||||
import ReturnResult from "Common/Types/IsolatedVM/ReturnResult";
|
||||
import BrowserType from "Common/Types/Monitor/SyntheticMonitors/BrowserType";
|
||||
@@ -17,6 +18,20 @@ export interface SyntheticMonitorOptions {
|
||||
script: string;
|
||||
}
|
||||
|
||||
interface BrowserLaunchOptions {
|
||||
executablePath?: string;
|
||||
proxy?: {
|
||||
server: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
bypass?: string;
|
||||
};
|
||||
args?: string[];
|
||||
headless?: boolean;
|
||||
devtools?: boolean;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export default class SyntheticMonitor {
|
||||
public static async execute(
|
||||
options: SyntheticMonitorOptions,
|
||||
@@ -131,9 +146,8 @@ export default class SyntheticMonitor {
|
||||
continue;
|
||||
}
|
||||
|
||||
scriptResult.screenshots[screenshotName] = (
|
||||
result.returnValue.screenshots[screenshotName] as any
|
||||
).toString("base64"); // convert screennshots to base 64
|
||||
const screenshotBuffer = result.returnValue.screenshots[screenshotName] as Buffer;
|
||||
scriptResult.screenshots[screenshotName] = screenshotBuffer.toString("base64"); // convert screenshots to base 64
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,12 +282,46 @@ export default class SyntheticMonitor {
|
||||
screenSizeType: data.screenSizeType,
|
||||
});
|
||||
|
||||
// Prepare browser launch options with proxy support
|
||||
const baseOptions: BrowserLaunchOptions = {};
|
||||
|
||||
// Configure proxy if available
|
||||
if (ProxyConfig.isProxyConfigured()) {
|
||||
const httpsProxyUrl = ProxyConfig.getHttpsProxyUrl();
|
||||
const httpProxyUrl = ProxyConfig.getHttpProxyUrl();
|
||||
|
||||
// Prefer HTTPS proxy, fall back to HTTP proxy
|
||||
const proxyUrl = httpsProxyUrl || httpProxyUrl;
|
||||
|
||||
if (proxyUrl) {
|
||||
baseOptions.proxy = {
|
||||
server: proxyUrl,
|
||||
};
|
||||
|
||||
// Extract username and password if present in proxy URL
|
||||
try {
|
||||
const parsedUrl = new URL(proxyUrl);
|
||||
if (parsedUrl.username && parsedUrl.password) {
|
||||
baseOptions.proxy.username = parsedUrl.username;
|
||||
baseOptions.proxy.password = parsedUrl.password;
|
||||
}
|
||||
} catch (error) {
|
||||
logger.warn(`Failed to parse proxy URL for authentication: ${error}`);
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
`Synthetic Monitor using proxy: ${proxyUrl} (HTTPS: ${!!httpsProxyUrl}, HTTP: ${!!httpProxyUrl})`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let page: Page | null = null;
|
||||
let browser: Browser | null = null;
|
||||
|
||||
if (data.browserType === BrowserType.Chromium) {
|
||||
browser = await chromium.launch({
|
||||
executablePath: await this.getChromeExecutablePath(),
|
||||
...baseOptions,
|
||||
});
|
||||
page = await browser.newPage();
|
||||
}
|
||||
@@ -281,6 +329,7 @@ export default class SyntheticMonitor {
|
||||
if (data.browserType === BrowserType.Firefox) {
|
||||
browser = await firefox.launch({
|
||||
executablePath: await this.getFirefoxExecutablePath(),
|
||||
...baseOptions,
|
||||
});
|
||||
page = await browser.newPage();
|
||||
}
|
||||
|
||||
115
Probe/Utils/ProxyConfig.ts
Normal file
115
Probe/Utils/ProxyConfig.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import { HTTP_PROXY_URL, HTTPS_PROXY_URL } from "../Config";
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
import { HttpsProxyAgent } from "https-proxy-agent";
|
||||
import { HttpProxyAgent } from "http-proxy-agent";
|
||||
import logger from "Common/Server/Utils/Logger";
|
||||
|
||||
export default class ProxyConfig {
|
||||
private static isConfigured: boolean = false;
|
||||
private static httpProxyAgent: HttpProxyAgent<string> | null = null;
|
||||
private static httpsProxyAgent: HttpsProxyAgent<string> | null = null;
|
||||
|
||||
public static configure(): void {
|
||||
if (this.isConfigured) {
|
||||
return; // Already configured
|
||||
}
|
||||
|
||||
if (!HTTP_PROXY_URL && !HTTPS_PROXY_URL) {
|
||||
logger.debug("No proxy URLs configured. Skipping proxy setup.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
logger.info("Configuring proxy settings:");
|
||||
if (HTTP_PROXY_URL) {
|
||||
logger.info(` HTTP proxy: ${HTTP_PROXY_URL}`);
|
||||
}
|
||||
if (HTTPS_PROXY_URL) {
|
||||
logger.info(` HTTPS proxy: ${HTTPS_PROXY_URL}`);
|
||||
}
|
||||
|
||||
// Create proxy agents for HTTP and HTTPS
|
||||
if (HTTP_PROXY_URL) {
|
||||
this.httpProxyAgent = new HttpProxyAgent(HTTP_PROXY_URL);
|
||||
}
|
||||
|
||||
if (HTTPS_PROXY_URL) {
|
||||
this.httpsProxyAgent = new HttpsProxyAgent(HTTPS_PROXY_URL);
|
||||
}
|
||||
|
||||
// Configure axios defaults to use the proxy
|
||||
if (this.httpProxyAgent) {
|
||||
axios.defaults.httpAgent = this.httpProxyAgent;
|
||||
}
|
||||
|
||||
if (this.httpsProxyAgent) {
|
||||
axios.defaults.httpsAgent = this.httpsProxyAgent;
|
||||
}
|
||||
|
||||
// Also configure proxy for axios instances
|
||||
axios.defaults.proxy = false; // Disable axios built-in proxy to use our agents
|
||||
|
||||
this.isConfigured = true;
|
||||
logger.info("Proxy configuration completed successfully");
|
||||
} catch (error) {
|
||||
logger.error("Failed to configure proxy:");
|
||||
logger.error(error);
|
||||
throw new Error(`Failed to configure proxy: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
public static isProxyConfigured(): boolean {
|
||||
return this.isConfigured && (!!HTTP_PROXY_URL || !!HTTPS_PROXY_URL);
|
||||
}
|
||||
|
||||
public static getHttpProxyUrl(): string | null {
|
||||
return HTTP_PROXY_URL;
|
||||
}
|
||||
|
||||
public static getHttpsProxyUrl(): string | null {
|
||||
return HTTPS_PROXY_URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP proxy agent for HTTP requests
|
||||
*/
|
||||
public static getHttpProxyAgent(): HttpProxyAgent<string> | null {
|
||||
return this.httpProxyAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTPS proxy agent for HTTPS requests
|
||||
*/
|
||||
public static getHttpsProxyAgent(): HttpsProxyAgent<string> | null {
|
||||
return this.httpsProxyAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure a specific axios instance to use the proxy
|
||||
* This is useful for cases where axios.create() is used
|
||||
*/
|
||||
public static configureAxiosInstance(instance: AxiosInstance): void {
|
||||
if (!HTTP_PROXY_URL && !HTTPS_PROXY_URL) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (HTTP_PROXY_URL) {
|
||||
const httpProxyAgent = new HttpProxyAgent(HTTP_PROXY_URL);
|
||||
instance.defaults.httpAgent = httpProxyAgent;
|
||||
}
|
||||
|
||||
if (HTTPS_PROXY_URL) {
|
||||
const httpsProxyAgent = new HttpsProxyAgent(HTTPS_PROXY_URL);
|
||||
instance.defaults.httpsAgent = httpsProxyAgent;
|
||||
}
|
||||
|
||||
instance.defaults.proxy = false;
|
||||
|
||||
logger.debug("Configured axios instance to use proxy");
|
||||
} catch (error) {
|
||||
logger.error("Failed to configure axios instance for proxy:");
|
||||
logger.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Probe/package-lock.json
generated
42
Probe/package-lock.json
generated
@@ -13,6 +13,8 @@
|
||||
"axios": "^1.7.2",
|
||||
"Common": "file:../Common",
|
||||
"ejs": "^3.1.10",
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
"https-proxy-agent": "^7.0.5",
|
||||
"ping": "^0.4.4",
|
||||
"playwright": "^1.50.0",
|
||||
"ts-node": "^10.9.1"
|
||||
@@ -71,6 +73,7 @@
|
||||
"crypto-js": "^4.2.0",
|
||||
"dotenv": "^16.4.4",
|
||||
"ejs": "^3.1.10",
|
||||
"elkjs": "^0.10.0",
|
||||
"esbuild": "^0.25.5",
|
||||
"express": "^4.21.1",
|
||||
"formik": "^2.4.6",
|
||||
@@ -1452,6 +1455,15 @@
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/agent-base": {
|
||||
"version": "7.1.4",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
|
||||
"integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-escapes": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
|
||||
@@ -1928,7 +1940,6 @@
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
@@ -2428,6 +2439,32 @@
|
||||
"integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/http-proxy-agent": {
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz",
|
||||
"integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"agent-base": "^7.1.0",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/https-proxy-agent": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
|
||||
"integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"agent-base": "^7.1.2",
|
||||
"debug": "4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/human-signals": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz",
|
||||
@@ -3804,8 +3841,7 @@
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"dev": true
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/natural-compare": {
|
||||
"version": "1.4.0",
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
"axios": "^1.7.2",
|
||||
"Common": "file:../Common",
|
||||
"ejs": "^3.1.10",
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
"https-proxy-agent": "^7.0.5",
|
||||
"ping": "^0.4.4",
|
||||
"playwright": "^1.50.0",
|
||||
"ts-node": "^10.9.1"
|
||||
|
||||
@@ -177,6 +177,8 @@ GLOBAL_PROBE_1_ONEUPTIME_URL=http://localhost
|
||||
GLOBAL_PROBE_1_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS=60000
|
||||
GLOBAL_PROBE_1_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS=60000
|
||||
GLOBAL_PROBE_1_PORT=3874
|
||||
# (Optional) If you want to use a proxy for the probe, then you can set the proxy URL here. For example, if you're using a proxy server like Caddy or Nginx, then you can set the proxy URL here.
|
||||
GLOBAL_PROBE_1_PROXY_URL=
|
||||
|
||||
GLOBAL_PROBE_2_NAME="Probe-2"
|
||||
GLOBAL_PROBE_2_DESCRIPTION="Global probe to monitor oneuptime resources"
|
||||
@@ -186,6 +188,8 @@ GLOBAL_PROBE_2_ONEUPTIME_URL=http://localhost
|
||||
GLOBAL_PROBE_2_SYNTHETIC_MONITOR_SCRIPT_TIMEOUT_IN_MS=60000
|
||||
GLOBAL_PROBE_2_CUSTOM_CODE_MONITOR_SCRIPT_TIMEOUT_IN_MS=60000
|
||||
GLOBAL_PROBE_2_PORT=3875
|
||||
# (Optional) If you want to use a proxy for the probe, then you can set the proxy URL here. For example, if you're using a proxy server like Caddy or Nginx, then you can set the proxy URL here.
|
||||
GLOBAL_PROBE_2_PROXY_URL=
|
||||
|
||||
SMS_DEFAULT_COST_IN_CENTS=
|
||||
CALL_DEFAULT_COST_IN_CENTS_PER_MINUTE=
|
||||
|
||||
Reference in New Issue
Block a user