개요
이 가이드에서는 SOCKS5 프록시를 사용하여 MongoDB에 연결하는 방법을 배울 수 있습니다. SOCKS5는 프록시 서버를 통해 네트워크 서비스와 통신하기 위한 표준화된 프로토콜입니다.
팁
SOCKS5 프로토콜에 대해 자세히 학습하려면 SOCKS.에 대한 Wikipedia 항목을 참조하세요.
SOCKS5 프록시 설정
프록시 설정은 SOCKS5 프록시 서버 주소 와 인증 자격 증명 지정합니다. 다음과 같은 방법으로 이러한 설정을 지정할 수 있습니다.
연결 URI에 매개 변수로 포함합니다.
MongoClientSettings인스턴스 에서Socks5ProxySettings속성Socks5ProxySettings클래스의 인스턴스 로 설정하다 .
다음 표에서는 SOCKS5 프록시 설정에 대해 설명합니다.
설정 | 설명 |
|---|---|
호스트 | Specifies the SOCKS5 proxy IPv4 address, IPv6 address, or hostname.
You must provide this value to connect to a SOCKS5 proxy. |
포트 | Specifies the TCP port number of the SOCKS5 proxy server. Default: 1080 |
인증 | Specifies the authentication settings the SOCKS5 proxy server.
You can use the UsernamePassword() method of the Socks5AuthenticationSettings
class to create authentication settings with your credentials. |
예시
다음 예시 SOCKS5 프록시를 사용하여 MongoDB deployment 에 연결하는 방법을 보여 줍니다.
var settings = new MongoClientSettings.FromConnectionString("<connection URI>"); var proxySettings = new Socks5ProxySettings( "<proxy host>", 1, Socks5AuthenticationSettings.UsernamePassword("<username>", "<password>")); settings.Socks5ProxySettings = proxySettings; var client = new MongoClient(settings);
var connectionURI = "mongodb://localhost:27017/" + "?proxyHost=<proxyHost>" + "&proxyPort=<proxyPort>" + "&proxyUsername=<proxyUsername>" + "&proxyPassword=<proxyPassword>"; var client = new MongoClient(connectionURI);
API 문서
이 가이드에서 사용되는 메서드 또는 유형에 대해 자세히 알아보려면 다음 API 문서를 참조하세요.