How do you use Sentry?
Sentry Saas (sentry.io)
Version
v2.57.0
Steps to Reproduce
Deploy a Django application behind a reverse proxy / load balancer (e.g. AWS ALB) with SSL termination.
Ensure the load balancer sends the following header:
X-Forwarded-Proto: https
Configure Django with:
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
USE_X_FORWARDED_HOST = True
Add a test endpoint to confirm how Django interprets the request:
def debug_headers(request):
return JsonResponse({
"X-Forwarded-Proto": request.META.get("HTTP_X_FORWARDED_PROTO"),
"request.scheme": request.scheme,
})
Verify that hitting this endpoint returns:
{
"X-Forwarded-Proto": "https",
"request.scheme": "https"
}
Enable Sentry in the Django app with default request integration.
Trigger an error and inspect the event in Sentry.
Expected Result
Sentry reports the request URL as http://...
Actual Result
Sentry should report the request URL as https://..., since Django resolves the request scheme as HTTPS.
How do you use Sentry?
Sentry Saas (sentry.io)
Version
v2.57.0
Steps to Reproduce
Deploy a Django application behind a reverse proxy / load balancer (e.g. AWS ALB) with SSL termination.
Ensure the load balancer sends the following header:
X-Forwarded-Proto: httpsConfigure Django with:
Add a test endpoint to confirm how Django interprets the request:
Verify that hitting this endpoint returns:
Enable Sentry in the Django app with default request integration.
Trigger an error and inspect the event in Sentry.
Expected Result
Sentry reports the request URL as http://...
Actual Result
Sentry should report the request URL as https://..., since Django resolves the request scheme as HTTPS.