Druid Proxy Server
1.7K
Druid Proxy Server is an Express-based proxy server, written in TypeScript, that securely forwards SQL queries to an Apache Druid instance. It is designed to enhance security by validating UUID v4 strings in requests and enforcing Bearer token authentication with UUID validation. This image provides a ready-to-run container for deploying the proxy server.
id query parameters and Bearer tokens as UUID v4 strings, enhancing security.Authorization header for access./health endpoint for monitoring container health.The recommended way to run this image is using Docker Compose.
Create a docker-compose.yml file:
version: "3.8"
services:
bnb-druid-proxy:
image: jlmconsulting/bnb-druid-proxy:latest
container_name: bnb-druid-proxy
ports:
- "3333:3333" # HTTPS Port
- "3334:3334" # HTTP Port (redirects to HTTPS)
environment:
- MONGO_CONNECTION_STRING=mongodb+srv://youruser:[email protected]/yourdb # Replace with your MongoDB connection string (if needed by backend logic)
- HTTPS_PORT=3333
- HTTP_PORT=3334
- DRUID_URL=http://your-druid-host:8888/druid/v2/sql # Replace with your Druid URL
- CERT_KEY_PATH=/usr/src/app/certs/privkey1.pem # Path inside container
- CERT_CERT_PATH=/usr/src/app/certs/fullchain1.pem # Path inside container
- CERT_CA_PATH=/usr/src/app/certs/ca.pem # Optional CA cert path inside container
# Add other environment variables as needed (see Configuration section)
volumes:
- ./certs:/usr/src/app/certs # Mount your certs directory
# network_mode: "host" # Uncomment if you need host network mode
Create a certs directory:
Create a directory named certs in the same directory as your docker-compose.yml file. Place your SSL certificate files (privkey1.pem, fullchain1.pem, and optionally ca.pem) inside this directory.
mkdir certs
# Copy your certificate files into the certs directory
# e.g., cp /path/to/your/privkey1.pem certs/
Run Docker Compose:
docker-compose up -d
This will start the Druid Proxy server in detached mode.
The following environment variables can be used to configure the Druid Proxy server:
| Variable | Description | Required | Default Value |
|---|---|---|---|
MONGO_CONNECTION_STRING | Your MongoDB connection string. This is used if your backend logic (beyond just proxying to Druid) requires a MongoDB connection. If the proxy is solely for Druid forwarding, this might not be strictly necessary depending on the routes you are using and their backend dependencies. Check the application's code to confirm if MongoDB is used. | No | None |
HTTPS_PORT | The port number for the HTTPS server. | No | 3333 |
HTTP_PORT | The port number for the HTTP server, which redirects all traffic to HTTPS. | No | 3334 |
DRUID_URL | The URL of your Apache Druid instance's SQL endpoint. Example: http://your-druid-host:8888/druid/v2/sql | Yes | None |
CERT_KEY_PATH | The path to your private key file (privkey1.pem) inside the container. When using Docker Compose, this should typically be set to /usr/src/app/certs/privkey1.pem if you mount your certs directory as shown in the Quick Start. | Yes | None |
CERT_CERT_PATH | The path to your full chain certificate file (fullchain1.pem) inside the container. When using Docker Compose, this should typically be set to /usr/src/app/certs/fullchain1.pem if you mount your certs directory as shown in the Quick Start. | Yes | None |
CERT_CA_PATH | (Optional) The path to your CA certificate file (ca.pem) inside the container. This is only required if you are using an intermediate CA certificate. When using Docker Compose, this should typically be set to /usr/src/app/certs/ca.pem if you mount your certs directory as shown in the Quick Start. | No | None |
NODE_OPTIONS | Allows you to set additional Node.js options. Useful for adjusting memory limits or other Node.js runtime configurations. Example: --max-old-space-size=8192 to increase the heap size to 8GB. | No | None |
HOST | The host address to bind the server to. Setting this to 0.0.0.0 makes the server accessible from outside the container. | No | localhost |
SONARQUBE_TOKEN | (Optional) SonarQube token, likely used for internal code quality checks or integrations. If not using SonarQube, you can ignore this. | No | None |
AWS_ACCESS_KEY_ID | (Optional) AWS Access Key ID. Potentially used for AWS integrations within the backend logic. Check the application code to determine its specific usage. | No | None |
AWS_SECRET_ACCESS_KEY | (Optional) AWS Secret Access Key. Potentially used for AWS integrations within the backend logic. Check the application code to determine its specific usage. | No | None |
AWS_REGION | (Optional) AWS Region. Potentially used for AWS integrations within the backend logic. Check the application code to determine its specific usage. | No | None |
BIDSNBUYS_USERNAME | (Optional) Username for "bidsnbuys" service. Likely used for authentication with an external service. Check the application code to determine its specific usage. | No | None |
BIDSNBUYS_PASSWORD | (Optional) Password for "bidsnbuys" service. Likely used for authentication with an external service. Check the application code to determine its specific usage. | No | None |
TOTP_SECRET | (Optional) TOTP secret. Likely used for Time-Based One-Time Password authentication with an external service. Check the application code to determine its specific usage. | No | None |
Important Notes:
certs directory and that the CERT_*_PATH environment variables correctly point to them inside the container. Volume mounting is used in the docker-compose.yml example to make certificates available within the container.MONGO_CONNECTION_STRING, AWS_SECRET_ACCESS_KEY, BIDSNBUYS_PASSWORD, and TOTP_SECRET. Avoid hardcoding sensitive information in your Docker Compose file. Use Docker secrets or environment variable management tools in production.DRUID_URL is correctly pointing to your Druid SQL endpoint and that the Druid instance is accessible from within the Docker container (or from the host if using network_mode: "host").Once the container is running, you can send requests to the proxy server.
Example curl command to query Druid via /v2/sql:
curl -X POST "https://your-server-address:3333/v2/sql?id=$(uuidgen)" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(uuidgen)" \
-d '{"query": "SELECT * FROM \\"your-druid-datasource\\""}' \
--cacert ./certs/fullchain1.pem # Replace with your cert path, or use --insecure for testing (not recommended for production)
Content type
Image
Digest
sha256:1a1f3de5c…
Size
777.7 MB
Last updated
over 1 year ago
docker pull jlmconsulting/bnb-druid-proxy