I Need Help On Implementing mod_gzip - c++

I'm working on a website that showed in the page source a suggestion to implement gzip compression to help my pages display faster. I have downloaded the zip file for mod_gzip 1.23.26.1a (latest version). I'm running Apache 2.4.14.
The link below is the installation instructions from the zip file. When you look at the section Static integration of mod_gzip it says in step 4 to read file INSTALL. The file is missing so I cannot use them to install mod_gzip.
http://schroepl.net/projekte/mod_gzip/install.htm
Note: When I open the index.hm file from the folder there is no link to the left that displays the install link above. I don't remember how I found that link. There are three makefile files but I have no idea what to do with them because the link gives no details.
I did find this link http://nadeausoftware.com/node/33 where I looked at the Mac steps in the section Enable file compression using mod_gzip. I guess these are valid instructions to implement mod_gzip. I don't know how to perform step 4: Compile the module using the included instructions. The documentation provided in the zip file does not have any compiling instructions that I could find. All I have are .c and .h files in the folder. The few places that I could find instructions were using files that end in .cpp. I don't know what I'm supposed to compile.
I would like to use mod_gzip to help speed up my websites but I don't know where else to find information on how to implement it.

I continued to search but could not find any answers to help me. During my search I found out that mod_deflate was available in apache2. Since there is an old debate between mod_gzip and mod_deflate with no consensus I decided to implement mod_deflate. I added the following statements to my apache config file which will compress all file types except images, files already compresses and pdf files. I have reviewed the log file and it's working well.
# HTTP compression using mod_deflate
LoadModule deflate_module ${MODULE_INSTALL_PATH_PREFIX}/usr/libexec/apache2/mod_deflate.so
<IfModule mod_deflate.c>
# compress all files types except the following
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|jpg|tif?|bmp|svg)$ \ 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
DeflateFilterNote Input input_info
DeflateFilterNote Output output_info
DeflateFilterNote Ratio ratio_info
LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
CustomLog /var/log/apache2/deflate_log deflate
</IfModule>

Related

Image files have got changed but pictures look the same

I recently have got many files (especially image thumbnails) changed mysterily on my server. I am trying to figure out what happened.
I found a .htaccess file under my site's image folder, the image folder is in the same directory of my homepage. But I did not upload this file to the server, and did not do any configuration on cPanel that generating this file. The code is as follows:
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_USER_AGENT} (google|yahoo|msn|aol|bing) [OR]
RewriteCond %{HTTP_REFERER} (google|yahoo|msn|aol|bing)
RewriteRule ^.*$ index.php [L]
</IfModule>
Can anyone help to interpret what the above code does? Thanks in advance.
And also, when I synchronized my local site and the remote site in Dreamweaver, there were always some images especially thumbnails changed on the server, Dreamweaver prompted "No synchronization necessary", but if I viewed the log, Dreamweaver did say "this file has been changed since last synchronization" but marked with "ignored", when I compared these changed files with local site, winmerge prompted that "the two files are identical". I assumed Dreamweaver did not really find out the changes.
However, the image files changed found by my cron job "find /MY PATH TO DIRECTORY -type f -mtime -1 -exec ls -ls" did shows the difference when I compared them in winmerge (I could see the differences but could not understand those code of the image files". My question is how the image files get changed, the pictures look the same but the information containing inside the file get changed, how the change could be done and what the change could be for? Is there any security issues?
Any help would be appreciated.
Seahorse.

How do I make .htaccess such that going to the folder will show the contents of the folder?

How do I make .htaccess such that going to the folder in the web browser, where .htacess resides, will show the contents of the folder? Maye this is not something achieved by .htacess file but has something to do with changing the permission of the folder("directory").
I do not want to use an index.html file at all because the contents of the directory (folder) will change and then the index.html will be invalid.
I have a follow-up question. After this is done, is there then a way to programmatically use C# code to get the contents of the directory listing?
So you're trying to access your folders directory via the web browser:
All you need to add is:
<IfModule mod_autoindex.c>
IndexOptions FancyIndexing IconHeight=16 IconWidth=16
</ifModule>
You will get something that looks a bit like this:
You can of course play around with the settings and add extra things like:
NameWidth=25
DescriptionWidth=40
IconsAreLinks
This is not necessary though, it really depends if this is just for you, or public access too. Does it need to be pretty :P
You can add an .htaccess file inside that specific folder then add this at the top of the .htaccess file. Remove any index.html file that you have there also.
Options +Indexes

How do I create an exception for mod security?

When I checked the logs, I found Mod_security blocking some files necessary
for the site operation. So far, I disabled it per domain in the apache configuration file.
I want to only disable certain rules on certain pages.The implementation examples I read are specific to red hat and other distros.
I run Centos 5 with apache 2.8 and mod_security 2 (the server hosts multiple sites)
On centos, the loaded mod_security is included on top like this:
Include "/usr/local/apache/conf/modsec2.conf"
The above file calls modsec2.user.conf that is found in the same directory.
Here's what I've done so far:
My server does not have a directory called modsecurity.d for me to create a file like this:
/etc/httpd/modsecurity.d/modsecurity_localrules.conf
So I created a file named:
whitelist.conf
in:
/usr/local/apache/conf/
then I added an include to it in:
/etc/httpd/conf/modsec2.conf/
the rules look like:
<LocationMatch "/wp-admin/post.php">
SecRuleRemoveById 950006
</LocationMatch>
But the rules are not working. I wonder if whitelist.conf was placed in the right place.
I then created 2 files:
modsecurity_crs_15_customrules.conf
modsecurity_crs_60_customrules.conf
and placed them in:
/home/cpeasyapache/src/modsecurity-apache_2.5.12/rules
The above path is where I found:
modsecurity_crs_10_config.conf
that contains main rules though I haven't seen it called by any other file.
Base rules are found in:
/home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/base_rules
It seems my mod_security is installed and configured with minimal functionality.am thinking to add this to httpd.conf:
<IfModule security2_module>
Include /home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/modsecurity_crs_10_config.conf
Include /home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/base_rules/*.conf
Include /home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/optional_rules/*.conf
Include /home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/modsecurity_crs_15_customrules.conf
Include /home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/modsecurity_crs_60_customrules.conf
</IfModule>
How do you guys do it on your end?
Thank you in advance

.htaccess caching with FilesMatch

I need to make browser caching with htaccess file.
From this question I found out how to add extensions to htaccess file.
<FilesMatch "\.(js|jpeg|jpg)$">
But I need to add extensions. But exclude some of the files.
I found something like this from this question
<FilesMatch ^((myfile|myfile2)\.js$|myphoto\.jpe?g)$>
Add all js and jpeg files except "myfile.js", "myfile2.js", "myphoto.jpg"
How can I do this?
Thank you
Try this
<FilesMatch "((?<!myfile|myfile2)\.js|(?<!myphoto).jpe?g)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
This will match all js and jpeg files except myfile.js, myfile2.js, and myphoto.jpeg using negative lookahead/lookbehind. Kind of ugly but I couldn't find a nice way to do this.
You can then have a separate files match for only those files and set a different header:
<FilesMatch "((myfile|myfile2)\.js|myphoto\.jpe?g)$">
Header set Cache-Control "max-age=3600, public"
</FilesMatch>

How to minify CSS/JS with mod-pagespeed and Django?

Just installed a recent version of mod-pagespeed on my django instance and tried to minify CSS/JS with the following pagespeed.conf but in vain, even though remove_comments and collapse_whitespace seemed to work out.
ModPagespeedEnableFilters rewrite_javascript,rewrite_css,flatten_css_imports
ModPagespeedEnableFilters collapse_whitespace,elide_attributes
ModPagespeedEnableFilters combine_javascript,remove_comments
In django templates, CSS/JS url was pointed by {{ STATIC_URL }}media/main.js, etc and the matching folder was set up as an alias at the apache setup, but JS/CSS (and its link) are all unchanged at all.
I suspect mod-pagespeed didn't pick up the js/css due to the intervention from template engine..?
I just finally found out the option that will make difference.
# Explicitly tell mod_pagespeed to load some resources from disk.
# This will speed up load time and update frequency.
#
# This should only be used for static resources which do not need
# specific headers set or other processing by Apache.
#
# Both URL and filesystem path should specify directories and
# filesystem path must be absolute (for now).
#
ModPagespeedLoadFromFile "http://example.com/static/" "/var/www/static/"
Commenting out ModPagespeedLoadFromFile and locate static folders for your js/css