mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-27 13:02:59 +02:00
ec7c99c270
1. Add agent setting for the proxy config 2. Add https-proxy-agent package Signed-off-by: AllForNothing <sshijun@vmware.com>
44 lines
1.1 KiB
Plaintext
44 lines
1.1 KiB
Plaintext
import HttpsProxyAgent from 'https-proxy-agent';
|
|
// Define the proxy configuration
|
|
const HarborProxyConfig = [
|
|
{
|
|
"context": [
|
|
"/api",
|
|
"/c",
|
|
"/i18n",
|
|
"/chartrepo",
|
|
"/LICENSE",
|
|
"/swagger.json",
|
|
"/swagger2.json",
|
|
"/devcenter-api-2.0",
|
|
"/swagger-ui.bundle.js"
|
|
],
|
|
"target": "${A Harbor server}",
|
|
"secure": false,
|
|
"changeOrigin": true,
|
|
"logLevel": "debug"
|
|
}
|
|
];
|
|
// Define if you use agent
|
|
const useAgent = false;
|
|
// Specify an agent server, if empty, will read it from environment variable http_proxy or HTTP_PROXY
|
|
const specifiedAgentServer = "${An agent server}";
|
|
|
|
function setupForCorporateProxy(proxyConfig) {
|
|
if (useAgent) {
|
|
const agentServer = process.env.http_proxy || process.env.HTTP_PROXY || specifiedAgentServer;
|
|
if (agentServer) {
|
|
const agent = new HttpsProxyAgent(agentServer);
|
|
console.log('Using corporate agent server: ' + agentServer);
|
|
proxyConfig.forEach(function(entry) {
|
|
entry.agent = agent;
|
|
});
|
|
}
|
|
}
|
|
return proxyConfig;
|
|
}
|
|
|
|
export default setupForCorporateProxy(HarborProxyConfig);
|
|
|
|
|