Skip to content

Commit

Permalink
Elasticsearch client config update for https connections
Browse files Browse the repository at this point in the history
  • Loading branch information
nitendra-new committed Oct 10, 2024
1 parent a2d889c commit 60d3579
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docker-compose-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ x-common-variables: &common-variables
POSTGRES_DATABASE: retraced
LOG_LEVEL: ${LOG_LEVEL}
ELASTICSEARCH_NODES: http://elasticsearch:9200
ELASTIC_PASSWORD: secret
ELASTIC_USER: elastic
NSQD_HOST: nsqd
HOSTNAME: retraced-api-67856674bf-kwq7f
NSQD_TCP_PORT: 4150
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export default {
RETRACED_DB_NO_CACHE: process.env.RETRACED_DB_NO_CACHE || env.RETRACED_DB_NO_CACHE,
ELASTICSEARCH_CAFILE: process.env.ELASTICSEARCH_CAFILE || env.ELASTICSEARCH_CAFILE,
ELASTICSEARCH_CACERT: process.env.ELASTICSEARCH_CACERT || env.ELASTICSEARCH_CACERT,
ELASTICSEARCH_USER: process.env.ELASTIC_USER || env.ELASTIC_USER,
LASTICSEARCH_PASSWORD: process.env.ELASTIC_PASSWORD || env.ELASTIC_PASSWORD,
HEADLESS_PROJECT_ENV: process.env.HEADLESS_PROJECT_ENV || env.HEADLESS_PROJECT_ENV,
RETRACED_PROCESSOR_LOG_FILE: process.env.RETRACED_PROCESSOR_LOG_FILE || env.RETRACED_PROCESSOR_LOG_FILE,
ELASTICSEARCH_REQUEST_RETRIES:
Expand Down
8 changes: 8 additions & 0 deletions src/persistence/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ function getElasticsearch(noRetry = false): Client {
? readFileSync(config.ELASTICSEARCH_CAFILE)
: Buffer.from(config.ELASTICSEARCH_CACERT, "base64");
sslSettings.rejectUnauthorized = true;
sslSettings.auth = {
username: config.ELASTICSEARCH_USER,
password: config.LASTICSEARCH_PASSWORD,
};
}

es = new Client({
Expand Down Expand Up @@ -195,6 +199,10 @@ export async function putAliases(toAdd: AliasDesc[], toRemove: AliasDesc[]): Pro
"Content-Type": "application/json",
},
httpsAgent: new https.Agent(httpsAgentParams),
auth: {
username: config.ELASTICSEARCH_USER,
password: config.LASTICSEARCH_PASSWORD,
},
});

return data;
Expand Down

0 comments on commit 60d3579

Please sign in to comment.