Skip to main content

Nginx Configuration

This guide explains how to configure Nginx as a reverse proxy for MCPHub, including SSL termination, load balancing, and caching strategies.

Basic Reverse Proxy Setup

Configuration File

Create or update your Nginx configuration file (/etc/nginx/sites-available/mcphub):

Enable the Configuration

Load Balancing Configuration

For high-availability setups with multiple MCPHub instances:

Caching Configuration

Browser Caching

Nginx Proxy Cache

Add to the http block in nginx.conf:

WebSocket Support

For real-time features and SSE (Server-Sent Events):

Security Configuration

Rate Limiting

IP Whitelisting

Monitoring and Logging

Access Logs

Status Page

Docker Integration

When running MCPHub in Docker, update the proxy configuration:

Complete Example Configuration

Here’s a production-ready example using the provided nginx.conf.example:

Troubleshooting

Common Issues

502 Bad Gateway: Check if MCPHub is running and accessible 504 Gateway Timeout: Increase proxy_read_timeout for long-running operations WebSocket connection failures: Ensure proper Upgrade and Connection headers Cache issues: Clear proxy cache or disable for development

Debug Commands

Performance Optimization

Worker Processes

Buffer Sizes

Keep-Alive

This configuration provides a solid foundation for running MCPHub behind Nginx with proper security, performance, and reliability features.