Add middleware for AWS ELB health check

This commit is contained in:
Dustin Pianalto 2019-12-25 22:00:25 -09:00
parent 05e1b01dd8
commit ce91071993
2 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1,8 @@
from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class AWSELBHealthCheckMiddleware(MiddlewareMixin):
def process_request(self, request):
if request.META("PATH_INFO") == '/hostcheck/':
return HttpResponse("It's Alive!")

View File

@ -137,6 +137,7 @@ AUTH_PASSWORD_VALIDATORS = [
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware # https://docs.djangoproject.com/en/dev/ref/settings/#middleware
MIDDLEWARE = [ MIDDLEWARE = [
"config.middleware.AWSELBHealthCheckMiddleware",
"django.middleware.security.SecurityMiddleware", "django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware", "django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.locale.LocaleMiddleware", "django.middleware.locale.LocaleMiddleware",