telnet http://address 80 GET / WML/1.2
Category: Apache
Apache 1.3 and 2.x Tips and tricks
Logging Apache Access logs through syslogd
Error logs can be logged very easyly to syslig using the following ErrorLog syslog:local1 Access logs must use a pipe-to-script trick as follows: In Apache config: CustomLog |/usr/local/apache/bin/apache_syslog combined As script in system: Content of /usr/local/apache/bin/apache_syslog ——————————————— logger -i -p local3.info -t TEST-APACHE ——————————————— chmod 755 /usr/local/apache/bin/apache_syslog
Brute force test Apache
apt-get install siege or apt-get install apache2-utils and use the program ‘ab‘ eg. /usr/sbin/ab -n 100 http://yoursite.com/
Running mod_gzip, mod_rewrite, and mod_proxy together in Apache 1.3.x
When using RewriteRule ….[P] with mod_gzip there are often problems To resolve this add the following directive to mod_gzip ———————————————– mod_gzip_item_include handler proxy-server ———————————————– mod_gzip_item_include mime “application/x-httpd-php.*” mod_gzip_item_include mime httpd/unix-directory mod_gzip_item_include handler ^server-status$ mod_gzip_item_exclude file \.css$ mod_gzip_item_exclude file \.js$ mod_gzip_item_exclude reqheader “Via:.*1\.0 PROXY” mod_gzip_item_exclude reqheader “Via:.*1\.0 lavoisier \(NetCache NetApp\/5\.0\.1R2\)”
Examples of mod_security diretives
SecFilterEngine On SecFilterScanPOST On SecFilterSelective “POST_PAYLOAD” “BoesesWort” “deny,log,status:412” # Ersetze BoesesWort durch das Wort, welches du sperren willst. # Speichere die Textdatei unter dem Namen .htaccess (den führenden Punkt nicht vergessen) SecFilterSelective “POST_PAYLOAD” “AnderesBoesesWort” “deny,log,status:412” # Alternative SecFilterSelective “POST_PAYLOAD” “BoesesWort” “deny,log,redirect:http.//www.deinedomain.de/seite.html”
Using curl to test PUT method to upload to web server
curl -u user:pass -T /home/guest/test.txt http://my.server.com:8082/upload/
MOD_JK configuration directives
see: http://tomcat.apache.org/connectors-doc/generic_howto/timeouts.html The following directives are normally inserted in workers.properties file connection_pool_minsize (default 0) defines, how many idle connections remain when the pool gets shrinked. By default this is half of the maximum pool size. connection_pool_size (default 0) We generally do not recommend to use this attribute in combination with Apache httpd. For Apache httpd …
Logging gzip compression factor of files
LogFormat “%h %l %u %t \”%r\” %>s %b mod_gzip:%{mod_gzip_result}n In:%{mod_gzip_input_size}nOut:%{mod_gzip_output_size}n:%{mod_gzip_compression_ratio}npct.” full_plus_gzip [17:29:14] CustomLog /var/log/httpd/mod_gzip.log full_plus_gzip Example of log entry: /reviews/cooling/HSR2_4.html HTTP/1.1″ 200 6289 mod_gzip: DECHUNK:OK In:23352 Out:6289:74pct.
Checkig the loading time a web site without loading its objects
date +%S.%N;w3m -dump http://www.mysite.de &>/dev/null;date +%S.%N
Selecting filtering what can be logged ‘per request’ level
SetEnvIfNoCase Request_URI “^/string to exclude/” drop and then between and CustomLog /var/log/httpd/www.mydomainname.com-access_log combined env=!drop
To UNSET an environment variable using SetIfEnv
eg. SetEnvIfNoCase Request_URI “.*\.html” !NOLOG Unsets the previously set NOLOG environment variable
Logformat code list
%…a: Remote IP-address %…A: Local IP-address %…B: Bytes sent, excluding HTTP headers. %…b: Bytes sent, excluding HTTP headers. In CLF format i.e. a ‘-‘ rather than a 0 when no bytes are sent. %…c: Connection status when response was completed. ‘X’ = connection aborted before the response completed. ‘+’ = connection may be kept alive …
To connect to SSL apache from command line
openssl s_client -connect localhost:443 -state -debug GET / HTTP/1.0