Running OpenSearch and Dashboards Behind Nginx with Docker Compose
OpenSearch is a powerful open-source search and analytics suite, and OpenSearch Dashboards provides a visual interface for exploring your data. In this guide, we’ll show you how to set up both tools behind an Nginx reverse proxy using Docker Compose — all in one file.
Why Use Nginx?
Placing Nginx in front of OpenSearch and Dashboards has several benefits:
- Unified access point (http://localhost:9200)
- Clean URLs for Dashboards (/_dashboards)
- Easier to add SSL or access control later
Docker Compose Setup
Here’s a ready-to-run docker-compose.yml that configures:
- OpenSearch 3.0
- OpenSearch Dashboards 3
- Nginx reverse proxy
- Custom routing for Dashboards
networks:
default:
driver: bridge
configs:
opensearch-nginx-config:
content: |
server {
listen 9200 default_server;
server_name _;
location / {
proxy_pass https://opensearch:9200;
proxy_ssl_verify off;
client_max_body_size 10M;
}
location /_dashboards {
proxy_pass http://dashboards:5601;
}
}
volumes:
opensearch-data:
services:
nginx:
image: nginx:alpine
ports:
- 9200:9200
mem_limit: 512M
configs:
- source: opensearch-nginx-config
target: /etc/nginx/conf.d/opensearch.conf
opensearch:
image: opensearchproject/opensearch:3.0.0
environment:
discovery.type: single-node
OPENSEARCH_JAVA_OPTS: -Xms1024m -Xmx1024m
OPENSEARCH_INITIAL_ADMIN_PASSWORD: Ax12123123aA=-*
volumes:
- opensearch-data:/usr/share/opensearch/data
mem_limit: 2000M
ulimits:
memlock:
soft: -1
hard: -1
dashboards:
image: opensearchproject/opensearch-dashboards:3
environment:
OPENSEARCH_HOSTS: http://nginx:9200
OPENSEARCH_USERNAME: admin
OPENSEARCH_PASSWORD: Ax12123123aA=-*
SERVER_BASEPATH: /_dashboards
SERVER_REWRITEBASEPATH: "true"
mem_limit: 1024M
Getting Started
- Save the file as docker-compose.yml.
- Run the stack using
docker compose up -d - Access your services
- OpenSearch API: http://localhost:9200
- Dashboards UI: http://localhost:9200/_dashboards
Security Tips
- Change the default password before going public.
- Use HTTPS with a reverse proxy or add Certbot to Nginx.
- Limit access with a firewall or network rules.
✅ Conclusion
This setup gives you a fully functional OpenSearch environment with a clean access point and minimal configuration. Perfect for development, internal tools, or as a base for production.