> Hi, Roberto and list readers,
>
> I have a need to implement SSL proxying via web proxy tunelling ("CONNECT"
> method) http://en.wikipedia.org/wiki/HTTP_tunnel.
> I'm thinking if it's possible to do it inside the existing
> nginx-uwsgi-gevent-django application.
>
> The whole idea of it is a big hack, but I'm curious if it's at all
> possible.
>
> To implement it, one should relay all the trafic between the target server
> and the client.
> Can I do it with uWSGI?
>
> Basically, I need something like a couple of threads or greenlets reading
> and writing to the raw socket when data is available on either end.
>
> Thanks for your reply.
>

I do not see particular problems implementing it with uWSGI+gevent, but
you cannot use django for it (its view subsystem will make mess with
realtime sockets).

basically you will end with something like:

if environ['REQUEST_METHOD'] == 'CONNECT':
    s = gevent.ssl.SSLSocket(..)
    s.connect()
    client_fd = uwsgi.connection_fd()
    server_fd = s.fileno()
    # wait for data on both end
    ready = gevent.select.select([client_fd, server_fd], [], [], timeout)
    ...
    # if it is the client send data to the server
    ... server_fd.write(client_fd.read(4096))
    # else...
    ... client_fd.write(server_fd.read(4096)

you need to add better check for non blocking writes, but generally this
is the approach i would follow



-- 
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to