Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elasticsearch client config update for https connections #1641

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo here

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
Loading