This guide supplements DEPLOY.md to provide comprehensive details on deploying IndicRAG in a production environment.
API Key authentication secures your endpoints. It is enabled by default in production.
- Open your
.envfile. - Define
API_KEYSwith a comma-separated list of your secure keys:API_KEYS=your_secure_key_1,your_secure_key_2
- All clients must include the following header when making API requests:
X-API-Key: your_secure_key_1
(Note: If API_KEYS is left empty or commented out, the API will be completely open. This is strictly meant for local development.)
The FastAPI server is instrumented with Prometheus FastAPI Instrumentator.
- Metrics are automatically tracked for all endpoints (latency, request counts, errors).
- Access the metrics endpoint at:
http://localhost:8000/metrics - Configure your centralized Prometheus scraper to pull from this
/metricsendpoint.
To secure traffic to your FastAPI server, use a reverse proxy like Nginx to handle SSL/TLS termination.
We have provided a sample configuration file at deploy/nginx.example.conf.
- Copy the example configuration to your Nginx sites directory:
sudo cp deploy/nginx.example.conf /etc/nginx/sites-available/indicrag sudo ln -s /etc/nginx/sites-available/indicrag /etc/nginx/sites-enabled/
- Obtain an SSL certificate using Let's Encrypt (Certbot):
sudo certbot --nginx -d api.indicrag.com
- Restart Nginx:
sudo systemctl restart nginx
Since Windows does not natively use systemd, nssm (Non-Sucking Service Manager) is the easiest way to run IndicRAG as a background Windows Service.
- Download NSSM: Get the latest executable from nssm.cc.
- Open Command Prompt as Administrator and run:
nssm install IndicRAG
- Configure the Service:
- Path: Path to your Python executable (e.g.,
C:\Python311\python.exeor the path in your virtual environmentd:\IndicRAG\venv\Scripts\python.exe). - Arguments:
start_server.py --port 8000 - Details tab: Set a description and startup type (Automatic).
- AppDirectory:
d:\IndicRAG - Environment tab: (Optional) define local environment variables, though
.envwill be picked up automatically.
- Path: Path to your Python executable (e.g.,
- Click "Install Service".
- Start the Service:
nssm start IndicRAG
You can now manage the API via the standard Windows Services interface (services.msc).
-
Provision a VM (Ubuntu 22.04 LTS recommended).
-
Install Python 3.11+, Git, and Nginx.
-
Clone the repository and install dependencies (
pip install -r requirements.txt). -
Follow the Nginx instructions above.
-
Setup a
systemdservice:[Unit] Description=IndicRAG API Server After=network.target [Service] User=ubuntu WorkingDirectory=/home/ubuntu/IndicRAG ExecStart=/usr/bin/python3 start_server.py Restart=always [Install] WantedBy=multi-user.target
Save to
/etc/systemd/system/indicrag.service, thensudo systemctl enable --now indicrag.