Proxy Views

This document covers the views provided by revproxy.views and all it’s public attributes

class revproxy.views.ProxyView

Proxies requests to a given upstream server and returns a Django Response.


from django.urls import re_path

from revproxy.views import ProxyView

urlpatterns = [
    re_path(r'(?P<path>.*)', ProxyView.as_view(upstream='')),



The URL of the proxied server. Requests will be made to this URL with path (extracted from appended to it. This attribute is mandatory.


Whether to add the REMOTE_USER to the request in case of an authenticated user. Defaults to False.


Whether to add the X-Forwarded-For and X-Forwarded-Proto headers to the request. Defaults to False.


The Content-Type that will be added to the response in case the upstream server doesn’t send it and if mimetypes.guess_type is not able to guess. Defaults to 'application/octet-stream'.


The max number of attempts for a request. This can also be an instance of urllib3.Retry. If set to None it will fail if the first attempt fails. The default value is None.


A list of tuples in the style (from, to) where from must by a valid regex expression and to a valid URL. If request.get_full_path matches the from expression the request will be redirected to to with an status code 302. Matches groups can be used to pass parts from the from URL to the to URL using numbered groups. By default no rewrite is set.


class CustomProxyView(ProxyView):
    upstream = ''
    rewrite = (
        (r'^/yellow/star/$', r'/black/hole/'),
        (r'^/red/?$', r''),

        # Example with numbered match groups
        (r'^/foo/(.*)$', r'/bar\1'),

Whether to only accept RFC-compliant cookies. If set to True, any cookies received from the upstream server that do not conform to the RFC will be dropped.


The buffering amount for streaming HTTP response(in bytes), response will be buffered until it’s length exceeds this value. None means using default value, override this variable to change.


class revproxy.views.DiazoProxyView

In addition to ProxyView behavior this view also performs Diazo transformations on the response before sending it back to the original client. Furthermore, it’s possible to pass context data to the view thanks to ContextMixin behavior through get_context_data() method.

See also

Diazo is an awesome tool developed by Plone Community to perform XSLT transformations in a simpler way. In order to use all Diazo power please refer to:


from django.urls import re_path

from revproxy.views import DiazoProxyView

proxy_view = DiazoProxyView.as_view(

urlpatterns = [
    re_path(r'(?P<path>.*)', proxy_view),

Example base.html

        <div id="content"></div>
        ...Fix all links in the docs (and README file etc) from old to new repo

Example diazo.xml


    <!-- Adds 'body' content from into theme #content -->
    <before css:theme-children="#content" css:content-children="body" />



The Django template to be used as Diazo theme. If set to None Diazo will be disabled. By default diazo.html will be used.


The absolute path for the diazo rules file. By default it will look for the file diazo.xml on the Django application directory. If set to None Diazo will be disabled.


By default Diazo changes the doctype for html5 to html4. If this attribute is set to True the doctype will be kept. This attribute only works if Diazo transformations are enabled.