Skip to content

Commit

Permalink
[http] TCP_CORK / TCP_NOPUSH by default
Browse files Browse the repository at this point in the history
[http] selectable gzip compression level
[docs] reverse proxy updated
  • Loading branch information
Eugeny committed Nov 14, 2013
1 parent 6f2e670 commit e49edea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ajenti/core.py
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions ajenti/http.py
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions docs/source/man/reverse-proxy.rst
Expand Up @@ -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;
Expand Down

0 comments on commit e49edea

Please sign in to comment.