diff --git a/pombola/middleware.py b/pombola/middleware.py index 38127ecc5..f348c99b5 100644 --- a/pombola/middleware.py +++ b/pombola/middleware.py @@ -1,4 +1,6 @@ from instances.models import Instance +import socket +from django.utils.deprecation import MiddlewareMixin class FakeInstanceMiddleware: """ @@ -12,3 +14,10 @@ def process_request(self, request): # speeches to any users of the site at the moment, so force # that no user of the site is regarded as its owner. request.is_user_instance = False + +# Which server behind load balancer served the request +class AddServerDetailsMiddleware(MiddlewareMixin): + def process_response(self, request, response): + server_hostname = socket.gethostname() + response['X-Server'] = server_hostname + return response diff --git a/pombola/settings/base.py b/pombola/settings/base.py index 203f08254..d2bf04d32 100644 --- a/pombola/settings/base.py +++ b/pombola/settings/base.py @@ -228,6 +228,7 @@ "pagination.middleware.PaginationMiddleware", "mapit.middleware.ViewExceptionMiddleware", "django.middleware.security.SecurityMiddleware", + "pombola.middleware.AddServerDetailsMiddleware", ) CORS_ALLOW_HEADERS = default_headers + ("HTTP_AUTHORIZATION", "SENTRY-TRACE")