# Nginx configuration for MCP servers at mcp.techmavie.digital
# This configuration supports multiple MCP servers under different paths
#
# Place this file in /etc/nginx/sites-available/mcp.techmavie.digital
# Then symlink: ln -s /etc/nginx/sites-available/mcp.techmavie.digital /etc/nginx/sites-enabled/
server {
listen 80;
server_name mcp.techmavie.digital;
# Redirect HTTP to HTTPS
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name mcp.techmavie.digital;
# SSL certificates (managed by Certbot)
ssl_certificate /etc/letsencrypt/live/mcp.techmavie.digital/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mcp.techmavie.digital/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# Root endpoint - list available MCP servers
location = / {
default_type application/json;
return 200 '{"name":"MCP Server Hub","servers":[{"name":"Malaysia Transit","path":"/malaysiatransit","description":"Real-time Malaysia public transit information","icon":"https://malaysiatransit.techmavie.digital/malaysiatransitlogo/Malaysia%20Transit%20Logo%20(Transparent).png"}],"documentation":"https://github.com/hithereiamaliff"}';
}
# Favicon - redirect to Malaysia Transit logo
location = /favicon.ico {
return 302 https://malaysiatransit.techmavie.digital/malaysiatransitlogo/Malaysia%20Transit%20Logo%20(Transparent).png;
}
# Malaysia Transit favicon
location = /malaysiatransit/favicon.ico {
return 302 https://malaysiatransit.techmavie.digital/malaysiatransitlogo/Malaysia%20Transit%20Logo%20(Transparent).png;
}
# ============================================================================
# Malaysia Transit MCP Server
# Endpoint: https://mcp.techmavie.digital/malaysiatransit/mcp
# ============================================================================
location /malaysiatransit/ {
# Proxy to Malaysia Transit MCP container
proxy_pass http://127.0.0.1:8180/;
# Required headers for Streamable HTTP transport
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Important for streaming responses
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
# For potential WebSocket upgrade (future compatibility)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# CORS headers (if not handled by the app)
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Methods "GET, POST, DELETE, OPTIONS" always;
add_header Access-Control-Allow-Headers "Content-Type, Accept, Authorization, Mcp-Session-Id" always;
add_header Access-Control-Expose-Headers "Mcp-Session-Id" always;
# Handle preflight requests
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET, POST, DELETE, OPTIONS";
add_header Access-Control-Allow-Headers "Content-Type, Accept, Authorization, Mcp-Session-Id";
add_header Access-Control-Max-Age 86400;
add_header Content-Length 0;
add_header Content-Type text/plain;
return 204;
}
}
# ============================================================================
# Add more MCP servers here in the future
# Example:
# location /another-mcp/ {
# proxy_pass http://127.0.0.1:8081/;
# # ... same proxy settings as above
# }
# ============================================================================
}