From e49edeabdf074ffac299800413e8d1a92568fe36 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Thu, 14 Nov 2013 14:23:02 +0300 Subject: [PATCH] [http] TCP_CORK / TCP_NOPUSH by default [http] selectable gzip compression level [docs] reverse proxy updated --- ajenti/core.py | 4 ++++ ajenti/http.py | 4 ++-- docs/source/man/reverse-proxy.rst | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ajenti/core.py b/ajenti/core.py index 85f3a2ceb..08775ee06 100644 --- a/ajenti/core.py +++ b/ajenti/core.py @@ -133,6 +133,10 @@ def run(): listener.listen(10) else: listener = socket.socket(socket.AF_INET6 if ':' in bind_spec[0] else socket.AF_INET, socket.SOCK_STREAM) + try: + listener.setsockopt(socket.IPPROTO_TCP, socket.TCP_CORK, 1) + except: + listener.setsockopt(socket.IPPROTO_TCP, socket.TCP_NOPUSH, 1) listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: listener.bind(bind_spec) diff --git a/ajenti/http.py b/ajenti/http.py index ef34d2d16..26569a293 100644 --- a/ajenti/http.py +++ b/ajenti/http.py @@ -139,12 +139,12 @@ def redirect(self, url): self.respond('302 Found') return '' - def gzip(self, content): + def gzip(self, content, compression=9): """ Returns a GZip compressed response with given ``content`` and correct headers """ io = StringIO() - gz = gzip.GzipFile('', 'wb', 9, io) + gz = gzip.GzipFile('', 'wb', compression, io) gz.write(content) gz.close() compressed = io.getvalue() diff --git a/docs/source/man/reverse-proxy.rst b/docs/source/man/reverse-proxy.rst index ae5e59fef..37cb92479 100644 --- a/docs/source/man/reverse-proxy.rst +++ b/docs/source/man/reverse-proxy.rst @@ -12,7 +12,9 @@ All Ajenti URLs are absolute and start with ``/ajenti:``, which makes it easy to listen 80; location /ajenti { + rewrite (/ajenti)$ / break; rewrite /ajenti/(.*) /$1 break; + proxy_pass http://127.0.0.1:8000; proxy_redirect / /ajenti/; proxy_set_header Host $host;