How to enable gzip on proxy servers on Apache
I’m starting to use the gunicorn django app using supervisord. Here my configuration:
supervisord (http://supervisord.org)
- Varnish: port 80
- Apache: port 8080
- gunicorn: port 4180 (/path/to/my/manage.py run_gunicorn localhost:4180)
Only the port 80 is exposed to other clients than localhost. The Varnish default backend is Apache (localhost:8080). I have a Drupal installation and a django installation on the same machine: since I want to expose django on the same domain at a defined location, I add to Apache this location:
ProxyRequests Off
ProxyPreserveHost On
Order deny,allow
Allow from all
\# on port 4180 gunicorn is running
\# @see /etc/supervisor.conf
ProxyPass /foo http://localhost:4180/
ProxyPassReverse /foo http://localhost:4180/
Order allow,deny
Allow from all
AddOutputFilterByType DEFLATE text/html
=> http://localhost:4180/
=> http://localhost:4180/
You can omit AddOutputFilterByType DEFLATE text/html: here I just take the response from gunicorn, compress and then serve to the client in this way:
(client) -\> varnish -\> apache -\> gunicorn
*(client)
* (X-Varnish-Cache: MISS) **
Here an example of what I get:
It’s a big page, but using gzip from 2 MB of the uncompressed page I get 417 KB gzipped text/html, less than 1/4 of the original!
Read also on the same topic: How to enable gzip on proxy servers on nginx
https://web.archive.org/web/20130715000000*/http://supervisord.org/ (https://web.archive.org)
https://web.archive.org/web/20130715000000*/https://www.varnish-cache.org/ (https://web.archive.org)
https://web.archive.org/web/20130715000000*/http://localhost:4180/ (https://web.archive.org)
/> ProxyPassReverse /foo <a href= (https://web.archive.org)
https://web.archive.org/web/20130715000000*/http://localhost:4180/ (https://web.archive.org)
/> Order allow,deny<br /> Allow from all<br /> <strong>AddOutputFilterByType DEFLATE text/html</strong></p></blockquote> <p>You can omit <strong>AddOutputFilterByType DEFLATE text/html</strong>: here I just take the response from gunicorn, compress and then serve to the client in this way:</p> <p><em>(client) -> varnish -> apache -> gunicorn</em></p> <p><em>(client)<br /> <em> (X-Varnish-Cache: MISS) </em></em></p> <p>Here an example of what I get:<br /> <a href= (https://web.archive.org)
Response: 20 (Success), text/gemini
| Original URL | gemini://chirale.org/2013-07-15_1205.gmi |
|---|---|
| Status Code | 20 (Success) |
| Content-Type | text/gemini; charset=utf-8 |