Created
July 2, 2021 14:49
-
-
Save parthibanloganathan/b0ca3decbd059014e12e1d48d7479ea4 to your computer and use it in GitHub Desktop.
Letterdrop Django Proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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