NodeJS Proxy Server einrichten
Wenn Sie von einer IDNT Compute Cloud Instanz auf das Internet zugreifen möchten, müssen Sie den IDNT Compute Cloud Proxy Server verwenden.
Proxy-Einstellungen für NodeJS
Für NodeJS-Anwendungen gibt es verschiedene Möglichkeiten, den Proxy-Server zu konfigurieren:
1. Umgebungsvariablen
Die einfachste Methode ist die Verwendung von Umgebungsvariablen:
export http_proxy=http://proxy.idnt.net:3128
export https_proxy=http://proxy.idnt.net:3128
export HTTP_PROXY=http://proxy.idnt.net:3128
export HTTPS_PROXY=http://proxy.idnt.net:3128
2. HTTP-Client-Konfiguration
Für Node.js HTTP-Requests können Sie den Proxy direkt konfigurieren:
const http = require('http');
const https = require('https');
const httpAgent = new http.Agent({
proxy: 'http://proxy.idnt.net:3128'
});
const httpsAgent = new https.Agent({
proxy: 'http://proxy.idnt.net:3128'
});
// Verwendung mit fetch oder axios
fetch('https://example.com', { agent: httpsAgent });
3. NPM Proxy-Konfiguration
Für NPM-Paket-Downloads:
npm config set proxy http://proxy.idnt.net:3128
npm config set https-proxy http://proxy.idnt.net:3128
Proxy-Server Details
- Proxy-Server: proxy.idnt.net
- Port: 3128
- Protokoll: HTTP
- Authentifizierung: Keine erforderlich
Weitere Informationen
Weitere Informationen zur Proxy-Konfiguration finden Sie in unseren verwandten Artikeln für Linux, WordPress und PHP.