Coder Social home page Coder Social logo

djproxy's People

Contributors

asherf avatar bitdeli-chef avatar blaix avatar ds10x avatar michaeljoseph avatar thomasw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

djproxy's Issues

Development broken in python < 2.7

The requests file this ships with installs a version of Django not compatible with Python 2.6. If you need to test things with that version of Python, you'll need to install a version of Django < 1.7.

Handle multiple set-cookie in http response

In case the server returns more than one set-cookie header, djproxy returns a single set-cookie header that is incomprehensible to the browser.

This bug is known and reported in the operation of request. It is appropriate to process this usecase to use the headers returned by urllib3 instead of the one from request.

For now, I have implemented this processing in a ForwardSetCookie middleware.

I have the impression that it should be part of the core of the library, not to be deported in a middleware. It is the role of the proxy to correctly manage headers, cookies, ... I can redo my PR if it's the case.

class ForwardSetCookie(object):
    """
    Handles the transmission of multiple cookies returned by a server as multiple set-cookie headers.

    Request merges the set-cookie headers into one. The default behavior is ok
    if the server returns only one cookie per http response.

    The browser will receive only one cookie.

    {
        Set-Cookie: hello=world; Expires=Wed, 21 Oct 2015 07:28:00 GMT, world=hello
    }

    instead

    {
        Set-Cookie: hello=world; Expires=Wed, 21 Oct 2015 07:28:00 GMT
        Set-Cookie: world=hello
    }
    pass

request.user is anonymous user

i want to check user permissions and then give him access to proxy.
but when i want to check request.user and its permissions, it give me Anonymous user however it is not anonymous!!!

    def process_request(self, proxy, request, **kwargs):
        if request.method != 'OPTIONS':
            _u = User.objects.get(username=request.user)
            if not _u.has_perm('dummy.cm'):
                return HttpResponse({"status": -1, "msg": "you don't have permission to be here"}, content_type='application/json', status=HTTP_403_FORBIDDEN)
            else:
                return response
        else:
            return response

Using the proxy with a prefix causes an issue with src/href links that start with '/'

URL links in proxied documents that begin with '/' always request the document at the url of the website. For example, if my website is www.example.com, and the proxy for an external site www.external.com is hosted at '/prefix/', if the proxied HTML document that is served as a response contains any links (href or src) starting with '/', for example, '/image/puppy.png', the link resolves to 'www.example.com/image/puppy.png' which is incorrect, since it ignores the prefix we have set up for the proxy.

bug in HttpProxy.__init__

Take look at a call of the base class' constructor here.

class HttpProxy(View):
    ...
    def __init__(self, *args, **kwargs):
        return super(View, self).__init__(*args, **kwargs)

It must be return super(HttpProxy, self).__init__(*args, **kwargs).

url() is deprecated in Django 3.1+

For anyone else looking for how to make this work in Django 3.1+, you'll find that url() is deprecated, so where you see this in the documentation:

url(r'^local_proxy/(?P<url>.*)$', LocalProxy.as_view(), name='proxy')

...change it to this:

path('local_proxy/<path:url>', views.LocalProxy.as_view(), name='proxy'),

(you could also use re_path(), but there's really no need)

I hope this helps someone out :-)

Passing CSRF tokens

Hi

I am trying to proxy requests to an internal Nginx server which in turn proxy_passes again. At the end, there is an IPython Notebook.

The problem is, that it complaints about missing CSRF cookie. Is there something special I need to set for that to work? Using the Nginx proxy directly works.

BTW: Is is also possible to proxy the websocket protocol?

Thanks!

Headers not passed from upstream to request

Forgive me if it's a noob question. I usually code in other programming language. I tried using this library to proxy request but i was getting garbage value in prod which connects to a https url. After struggling i figured out that the headers is not passed from upstream to the proxy request. so i wrote a middle ware and added it to make it work. Is that intentional or bug ?

The middleware looks like this

class AddHeaders(object):

    def process_response(self, proxy, request, upstream_response, response):
        return HttpResponse(response.content, headers=upstream_response.headers)

reverse_urls help

Trying to use ReverseProxy on Django 2.1 but is does not add the location headers.
Later I see that it is only tested on Django 1 version.
Will this project get into a Version 2 release ?

websockets/channels

Hi thomas,
great proxy you have developed there, thanks in first place ๐Ÿ‘
Just a question if you took a look already at supporting websockets via the django-channels project? I was said to be included in django 1.10 but it wasn't but i wanted to ask if you would consider supporting it anyway??
Thanks!

base_url same site?

I want to set up a reverse proxy that will proxy a Django app URL to another part of the same website that is outside of Django.

(for example):

www.mysite.com/MyDjangoApp/foo/* -> www.mysite.com/bar/*

And of course, I need this to work for whatever domain/server the app is installed on.

The example in the docs only shows proxying to a static upstream domain (base_url = 'https://google.com/'). How can I set "base_url" in order to use whatever server the original request was made to, instead of always going to a specific domain?

It this isn't specifically configurable, I suppose I could look at request.META['HTTP_HOST'] to find out what server to use, but is there a method that I can hook into where I will have access to the request, and also be able to set base_url at runtime?

Question. Reverse Proxy.

Hello Team,

Thank you for your efforts with this library.
I am confused about something. When configuring the middleware to ProxyPassReverse in the view, should I expect all links in the response content to the user (for example images inside the Html page) are going to be changed to the hostname the one is doing the proxy? I could not make this work. Am I doing something wrong?

Thank you, I appreciate it.
M

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.