Node.js 및 TypeScript
연결 풀을 활용하면서 undici, axios, 네이티브 fetch 또는 SOCKS5로 Node.js와 TypeScript 요청을 전용 고정 IPv4로 보내세요.
이 페이지의 목차8
적합한 클라이언트는 프록시 프로토콜과 Node.js 런타임 버전에 따라 달라지므로 스택에 맞는 패턴을 선택하세요.
| 클라이언트 | 프록시 스킴 | 적합한 용도 |
|---|---|---|
undici(ProxyAgent) |
https://, http:// |
fetch를 사용하는 Node 20+ 서버 및 서버리스 함수의 기본 권장 |
axios + https-proxy-agent |
https://, http:// |
기존 axios 코드베이스 |
네이티브 fetch + NODE_USE_ENV_PROXY=1 |
https://, http:// |
Node 22.21+ 및 Node 24+에서 의존성 없이 사용 |
socks-proxy-agent |
socks5h:// |
SOCKS5가 필요한 node:https 또는 axios 클라이언트 |
1단계. 프록시 URL 가져오기
- Prontaro 대시보드(my.prontaro.com/ips)에서 IP 주소를 열고 전용 IPv4를 선택합니다.
- 프록시 인증 정보에서
HTTPS프록시 URL(:443)을 복사합니다.
프록시 문자열을 PRONTARO_PROXY_URL로 내보냅니다.
export PRONTARO_PROXY_URL="https://user:pass@<entry>.prontaro.io:443"undici(ProxyAgent) — 권장
undici를 설치하고 요청들이 단일 TCP/TLS keep-alive 풀을 공유하도록 모듈 수준에 ProxyAgent를 하나만 생성하세요.
npm install undici// egress-client.ts
import { fetch, ProxyAgent } from 'undici';
const proxyUrl = process.env.PRONTARO_PROXY_URL;
if (!proxyUrl) {
throw new Error('PRONTARO_PROXY_URL is not set');
}
// One shared agent per process — do not close it after every request
export const proxyAgent = new ProxyAgent({
uri: proxyUrl,
connections: 10,
});
export async function checkOutboundIp(): Promise<string> {
const res = await fetch('https://api.ipify.org', {
dispatcher: proxyAgent,
signal: AbortSignal.timeout(15_000),
});
if (!res.ok) {
throw new Error(`HTTP ${res.status}: ${await res.text()}`);
}
return (await res.text()).trim();
}
// Close only during graceful process shutdown
process.once('SIGTERM', () => {
void proxyAgent.close();
});
console.log(await checkOutboundIp());발신 IP를 확인합니다.
npx tsx egress-client.ts
203.0.113.10api.ipify.org가 전용 IPv4를 반환하는 것을 확인한 뒤 대시보드(IP 주소 → 프록시 인증 정보 → 접근)에서 목적지를 제한할 수 있습니다.
axios + https-proxy-agent
Axios의 내장 proxy 옵션은 https:// 프록시 호스트 처리에 문제가 있고 환경 변수와 충돌할 수 있습니다. HttpsProxyAgent를 httpsAgent로 전달하고 명시적으로 proxy: false를 설정하세요.
npm install axios https-proxy-agent// axios-client.ts
import axios from 'axios';
import { HttpsProxyAgent } from 'https-proxy-agent';
const proxyUrl = process.env.PRONTARO_PROXY_URL;
if (!proxyUrl) {
throw new Error('PRONTARO_PROXY_URL is not set');
}
const httpsAgent = new HttpsProxyAgent(proxyUrl);
export const partnerApi = axios.create({
httpsAgent,
proxy: false, // disable Axios's built-in HTTP_PROXY handling
timeout: 15_000,
});
const { data } = await partnerApi.get<string>('https://api.ipify.org');
console.log(data.trim());NODE_USE_ENV_PROXY=1과 네이티브 fetch(Node 22 / 24)
Node.js 24+ 및 Node.js 22.21+에서는 NODE_USE_ENV_PROXY=1(또는 --use-env-proxy)로 실행하면 내장 fetch()가 추가 의존성 없이 HTTPS_PROXY, HTTP_PROXY, NO_PROXY를 자동으로 따릅니다.
// check-env.mjs
const res = await fetch('https://api.ipify.org', {
signal: AbortSignal.timeout(15_000),
});
if (!res.ok) {
throw new Error(`HTTP ${res.status}`);
}
console.log((await res.text()).trim());HTTPS_PROXY="$PRONTARO_PROXY_URL" \
NO_PROXY="localhost,127.0.0.1,::1,169.254.169.254,.internal" \
NODE_USE_ENV_PROXY=1 \
node check-env.mjs프로세스 내 모든 fetch() 호출에 적용되므로 내부 서비스와 텔레메트리가 Prontaro를 우회하도록 항상 NO_PROXY를 설정하세요.
socks-proxy-agent를 이용한 SOCKS5(socks5h://)
undici.ProxyAgent는 http://와 https://만 지원합니다. socks5h://(:1080)에는 SocksProxyAgent를 axios나 node:https와 함께 사용하세요.
npm install axios socks-proxy-agent// socks-client.ts
import axios from 'axios';
import { SocksProxyAgent } from 'socks-proxy-agent';
// Use socks5h:// so DNS resolves on the Prontaro server
const socksUrl = process.env.PRONTARO_SOCKS_URL; // socks5h://user:pass@<entry>.prontaro.io:1080
if (!socksUrl) {
throw new Error('PRONTARO_SOCKS_URL is not set');
}
const socksAgent = new SocksProxyAgent(socksUrl);
const { data } = await axios.get<string>('https://api.ipify.org', {
httpAgent: socksAgent,
httpsAgent: socksAgent,
proxy: false,
timeout: 15_000,
});
console.log(data.trim());자주 발생하는 Node.js 실수
- 전역
fetch와 npmundici혼용: 내장 undici와의 버전 차이로dispatcher가 깨지므로fetch와ProxyAgent모두'undici'에서 가져오세요. axios에서proxy: false누락:httpsAgent와 함께HTTPS_PROXY가 설정되어 있으면 Axios가 요청을 이중 프록시하려 시도합니다.SocksProxyAgent를fetch({ dispatcher })에 전달:SocksProxyAgent는undici.Dispatcher가 아니라 Node의http.Agent를 구현합니다.- 요청마다 에이전트 생성: 핸들러에서
new ProxyAgent(...)를 매번 만들면 TLS 핸드셰이크가 반복되어 IP당 동시 연결 한도에 도달할 수 있습니다.
Relay URL로 API 호출하기
프록시 에이전트를 설정할 수 없는 엣지 런타임이나 코드베이스에서는 대시보드(IP 주소)에서 Relay를 만들고 fetch로 직접 호출하세요.
const res = await fetch(`${process.env.PRONTARO_RELAY_URL}/v1/status`, {
headers: {
Authorization: `Bearer ${process.env.PARTNER_API_TOKEN}`,
// 비밀번호를 설정한 경우에만 포함(대시보드의 'IP 주소 → Relay 주소 → 접근'):
'Prontaro-Relay-Auth': `${process.env.RELAY_LOGIN}:${process.env.RELAY_PASSWORD}`,
},
signal: AbortSignal.timeout(15_000),
});
if (!res.ok) {
throw new Error(`HTTP ${res.status}: ${await res.text()}`);
}
console.log(await res.json());TLS 종료 세부 사항과 한도는 Relay URL을 참고하세요.
다음 단계
- curl 및 환경 변수 —
curl -v로407및403오류 진단. - HTTP 및 SOCKS5 프록시 —
access,targets허용 목록 설정 및 인증 정보 교체. - Vercel용 고정 IP — Vercel Functions에서 프록시와 Relay URL 구성.
- AWS Lambda용 고정 IP — VPC 설정이나 NAT Gateway 없이 고정 IP 사용.
이 페이지에 문제가 있나요? 문의하기