Reverse Proxy Setup

To prepare your Cortensor Router Node for production use and support future scaling, it is recommended to set up an Nginx reverse proxy in front of your API service. This setup enables secure HTTPS access, controlled endpoint exposure, and load distribution across multiple router nodes.

Why Use a Reverse Proxy?

  • Production-Ready Architecture: Adds SSL, security headers, CORS, and configurable access control.

  • Scalability: Makes it easier to load balance requests across multiple router nodes.

  • Security: Hides internal ports and enables HTTPS via Let's Encrypt.

  • Routing Control: Restricts access to specific endpoints and protects internal services.


Setup Guide

1. Prerequisites

  • A running Cortensor Router Node (cortensord ~/.cortensor/.env routerv1)

  • Public domain pointing to your VPS (e.g., router.example.com)

  • Root access (sudo) on your node server

  • Ports 80 and 443 open on your firewall


2. Installation Script

Run the official Cortensor Nginx installer on your Router Node host:

sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/cortensor/installer/main/install-nginx-linux.sh)"

This will:

  • Install Nginx and Certbot

  • Prompt you to enter your domain

  • Use the preset template: router-node.nginx.template

  • Generate and apply a complete reverse proxy config for your Router Node

  • Optionally install HTTPS using Let’s Encrypt


3. API Server Configuration

Ensure your Router Node API is running on port 5010 (default):

cortensord ~/.cortensor/.env routerv1

Update your .env:

API_ENABLE=1
API_KEY=<your_generated_key>
API_PORT=5010

If DNS is properly configured, the installer will prompt you to secure your router domain via Certbot. You can always run this manually later:

sudo certbot --nginx -d router.example.com

5. Sample Architecture Diagram

Client (Web2/Web3) 

Cloudflare or DNS/CDN

Nginx Reverse Proxy (SSL + Routing)

Router Node (REST API)

Session Queue ↔ Miners

Available Endpoints (by default)

The reverse proxy allows access only to these:

  • /api/v1/info

  • /api/v1/status

  • /api/v1/miners

  • /api/v1/sessions

  • /api/v1/completions

  • /api/v1/tasks

  • /api/v1/ping

All other routes return 404.


CORS Configuration

The template includes both:

  • Restricted CORS: Allow specific trusted origins

  • Permissive CORS: (commented by default) allows all origins

Update CORS settings in:

/etc/nginx/sites-available/router-node.conf

Maintenance Commands

# Restart Nginx after config changes
sudo systemctl restart nginx

# Check status
sudo systemctl status nginx

Notes

  • This setup is designed for private router nodes. Load balancing and auto-scaling support will be introduced in future versions.

  • Make sure the API port (5010) is not exposed publicly when reverse proxy is enabled.


What’s Next?

  • Support for multi-router failover

  • Integration with Cortensor Dashboard & Metrics

  • Dynamic scaling across multiple router nodes

Last updated