UnixServerAdmin

Server Administration & Management

How to enable gzip (web Page) compression in Apache

First lets be sure your server supports compression, to do that it needs to have the mod_deflate module:

# cat httpd.conf | grep deflate

You should see this:

LoadModule deflate_module modules/mod_deflate.so

If it is commented, comment it out and add following lines :-

# vim /etc/httpd/conf/httpd.conf

#################################################
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE

# You can’t compress what is already compressed
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

# Make proxies work as they should.
<IfModule mod_headers.c>
Header append Vary User-Agent
</IfModule>

</IfModule>

#BrowserMatch ^Mozilla/4 gzip-only-text/html
#BrowserMatch ^Mozilla/4\.0[678] no-gzip
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
#################################################

March 28, 2013 Posted by | Apache | , | Leave a comment

How to enable gzip compression in Tomcat

Add the following attributes to the <Connector> in Tomcat’s server.xml to enable gzip compression of responses at line no.- 70 :-

# vim apache-tomcat/conf/server.xml

    compression=”on” compressionMinSize=”2048″
    compressableMimeType=”text/html,text/xml,text/csv,text/css,text/javascript”

Before

<Connector port=”8080″ protocol=”HTTP/1.1″
                 connectionTimeout=”20000″
                 redirectPort=”8443″ /

After

<Connector port=”8080″ protocol=”HTTP/1.1″
               connectionTimeout=”20000″
               redirectPort=”8443″
               compression=”on” compressionMinSize=”2048″
               compressableMimeType=”text/html,text/xml,text/csv,text/css,text/javascript” />

March 23, 2013 Posted by | Tomcat | , | 1 Comment

Protected: backup_script_encrypt.sh (in bzip2 format)

This content is password protected. To view it please enter your password below:

March 18, 2013 Posted by | Security, Shell Script | , | Enter your password to view comments.

Protected: backup_script_encrypt.sh (in tar.gz format)

This content is password protected. To view it please enter your password below:

March 13, 2013 Posted by | Security, Shell Script | , | Enter your password to view comments.

bzip2: (stdin): trailing garbage after EOF ignored

You may receive the following warning during extraction:

bzip2: (stdin): trailing garbage after EOF ignored

This seems harmless, you can get rid of it by either writing the archive to disk before transfer or using gzip instead of bzip2. The archive still decompresses fine, but tar is apparently outputting some additional garbage when using bzip2 and outputting to stdout. I personally still using bzip2 and stdout, as the advantages (greater compression ratio, no temp disk space required) outweigh the disadvantages.

March 8, 2013 Posted by | Security, Tips & Tricks, Unix/Linux | , , | Leave a comment

Protected: backup_dump_encrypt.sh (in tar.gz format)

This content is password protected. To view it please enter your password below:

March 3, 2013 Posted by | Security, Shell Script | , | Enter your password to view comments.