Skip to content

Commit 22a19fb

Browse files
committed
add proxyheaders firmware
Signed-off-by: Madhav Kandukuri <[email protected]>
1 parent 1a8b6f8 commit 22a19fb

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

mcpgateway/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
from sqlalchemy.exc import IntegrityError
5555
from sqlalchemy.orm import Session
5656
from starlette.middleware.base import BaseHTTPMiddleware
57+
from starlette.middleware.proxy_headers import ProxyHeadersMiddleware
5758

5859
# First-Party
5960
from mcpgateway import __version__
@@ -476,6 +477,9 @@ async def __call__(self, scope, receive, send):
476477
# Add streamable HTTP middleware for /mcp routes
477478
app.add_middleware(MCPPathRewriteMiddleware)
478479

480+
# Trust all proxies (or lock down with a list of host patterns)
481+
app.add_middleware(ProxyHeadersMiddleware, trusted_hosts="*")
482+
479483

480484
# Set up Jinja2 templates and store in app state for later use
481485
templates = Jinja2Templates(directory=str(settings.templates_dir))

run-gunicorn.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,6 @@ exec gunicorn -c gunicorn.config.py \
8282
--max-requests-jitter "${GUNICORN_MAX_REQUESTS_JITTER}" \
8383
--access-logfile - \
8484
--error-logfile - \
85+
--forwarded-allow-ips="*" \
8586
${SSL_ARGS} \
8687
"mcpgateway.main:app"

0 commit comments

Comments
 (0)