Skip to content

Instantly share code, notes, and snippets.

@dec1985
dec1985 / reverse_proxy_view.py
Created April 6, 2018 08:13 — forked from JustinTArthur/reverse_proxy_view.py
A Django 1.4+ view function that acts as a reverse proxy. Great for testing locally or for using as a starting point to code that needs to cache or manipulate the proxied response. If one needs to proxy in production without any response manipulation, performing this in the web container (like nginx or apache) would be recommended instead of thi…
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def reverse_proxy(request):
"""
Reverse proxy for a remote service.
"""
path = request.get_full_path()
#Optionally, rewrite the path to fit whatever service we're proxying to.