Apache enable compress on reverse proxy
Through Apache it is possible to enable the compression of the contents before they are sent to the http client (browser generally), all this through the “mod_deflate” module.
To enable the deflate module you need to run the “a2enmod deflate” command and restart the apache service.
A very interesting thing is that this functionality is usable even if apache is configured as a reverse proxy by simply adding a couple of lines:
“AddOutputFilterByType DEFLATE text / html text / plain text / xml text / css text / javascript application / javascript”
and
SetOutputFilter INFLATE; DEFLATE
The first line allows you to specify the contents that will be compressed / decompressed in the request / response and the second one inside the “location” tag says to apply the mod_deflate to the contents that come from your server. below is an example of configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<VirtualHost *:443> ServerName yousitename.com ServerAlias yousitename.com *.yousitename.com ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> SSLProxyEngine on ProxyPass / https://192.168.xxx.xxx:18000/ ProxyPassReverse / https://192.168.xxx.xxx:18000/ AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript #SSLProxyCheckPeerName off #SSLProxyCheckPeerCN off SSLProxyCheckPeerExpire off <Location /> Order deny,allow Allow from all SetOutputFilter INFLATE;DEFLATE </Location> SSLEngine on SSLCertificateFile /home/syna/ssl-yousitename.com/yousitename.com.crt SSLCertificateKeyFile /home/syna/ssl-yousitename.com/yousitename.com.key SSLCertificateChainFile /home/syna/ssl-yousitename.store/ca-bundle.crt </VirtualHost> |