Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save parthibanloganathan/b0ca3decbd059014e12e1d48d7479ea4 to your computer and use it in GitHub Desktop.
Save parthibanloganathan/b0ca3decbd059014e12e1d48d7479ea4 to your computer and use it in GitHub Desktop.
Letterdrop Django Proxy
class LetterdropProxy(HttpProxy):
base_url = 'https://{domain}.letterdrop.com'
verify_ssl = True
proxy_middleware = [
'djproxy.proxy_middleware.AddXFF',
'djproxy.proxy_middleware.AddXFH',
'djproxy.proxy_middleware.AddXFP',
'{pathToAddXFS class}.AddXFS'
]
class LetterdropAssetProxy(HttpProxy):
base_url = 'https://{domain}.letterdrop.com/_next/'
verify_ssl = True
proxy_middleware = [
'djproxy.proxy_middleware.AddXFF',
'djproxy.proxy_middleware.AddXFH',
'djproxy.proxy_middleware.AddXFP',
'{pathToAddXFS class}.AddXFS'
]
from django.http.response import HttpResponse
class AddXFS(object):
"""Add an updated X-Forwarded-Server header to the upstream request."""
def process_request(self, proxy, request, **kwargs):
kwargs['headers']['X-Forwarded-Server'] = "{replacewithyoursite.com}";
return kwargs
def process_response(self, proxy, request, upstream_response, response):
return HttpResponse(response.content, headers=upstream_response.headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment