Extracted from: http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#logformat Format String Description ============= ============================================================================================================ %% The percent sign %a Remote IP-address %A Local IP-address %B Size of response in bytes, excluding HTTP headers. %b Size of response in bytes, excluding HTTP headers. In CLF format, i.e. a ‘-‘ rather than a 0 when no bytes are sent. %{Foobar}C The contents of …
Category: Apache
Apache 1.3 and 2.x Tips and tricks
Remote logging of Apache logs
Since Apache doesn’t provide the possibility to send it’s logs to a remote server we use the PIPE loging capability as follows: Principle: ====== 1) – Send logs to a local script via STDOUT 2) – The script uses the command logger to send each log line to the local rsyslog 3) – rsyslog via …
Apache mod_deflate controls
Ive been looking for a way to set the DEFLATE globally and then disable it individually as needed either in vhosts or in containers. There are two way to configure the DEFLATE: – INCLUDE-ALL-with-Exceptions : Compress all content except the exceptions defined – EXCLUDE-ALL-with-Exceptions : Compress none of the contents except the exceptions defined The …
IP List of China and Korea for IPTABLES
Just download: http://www.okean.com/antispam/iptables/rc.firewall.sinokorea This script that can be downloaded regularly needs to be converted before it can be used. In this list the destination ports is 25 (SMTP). For web access blocking, the port needs to be changed to 80,443,25,110,22,995 etc. . A small script can be used to get the list, convert it before …
Get the country and city of client IP
wget -O- -q http://api.hostip.info/get_html.php?ip=195.80.230.182 or lynx -dump “http://api.hostip.info/get_html.php?ip=195.80.230.182”
Compile Apache 2 in Debian/Ubuntu/Mint/..
Introduction: Steps to compile Apache: – Installation of needed development packages – Prepare the directories needed – copy the config file and script below – Run the script below Installation of needed development packages Needed for Apache mod_deflate libzip-dev (sources) libzip1 (bin libs.) zlib1g-dev (sources) Needed for Mod_security libpcre3-dev libpcrecpp0 libxml2-dev Compiling script Configuration file …
Get the response content in terminal
w3m -dump http://my.server.com
Preventing loging for some documents types
eg. SetEnvIfNoCase Request_URI “.*\.html” !NOLOG CustomLog /var/log/httpd/main.log j_common env=!NOLOG
Get RSS with bash
#!/bin/bash lynx -source http://rss.freshmeat.net/freshmeat/feeds/fm-releases-global | sed -n ‘s/.*//gp’ | sed ‘s/
Compiling a new standard Apache DSO module
# Build and install a distributed Apache module, say mod_foo.c, into its own DSO mod_foo.so: * Build and install via configure (preferred): $ ./configure –prefix=/path/to/install –enable-shared=foo $ make install * Build and install manually: – Edit src/Configuration: > SharedModule modules/xxxx/mod_foo.so $ make $ cp src/xxxx/mod_foo.so /path/to/install/libexec – Edit /path/to/install/etc/httpd.conf >> LoadModule foo_module /path/to/install/libexec/mod_foo.so # Build …
Mod_jk shared file size in Apache 1.3.x
It can occur that a new worker set prevents apache to start, although correct configured. Possible cause: Mod_JK shared file is too small Size must be at least: Header: 84 Bytes Per Worker: 400 Bytes Extra at the end: 800 Bytes Any type worker uses the same amount of memory(400 bytes): loadBalancers and hosts Configuration: …
Example of mod_security Configuration
SecFilterEngine DynamicOnly SecFilterScanPOST On SecFilterDefaultAction “deny,log,status:400” SecFilterSelective REQUEST_URI “
MOD GZIP Configuration in Apache 1.3.x
NOTE: The size of the zipped content(not header) is about 1/3 of original size. mod_gzip_command_version ‘/mod_gzip_status’ mod_gzip_temp_dir /tmp/mod_gzip_httpd mod_gzip_keep_workfiles No mod_gzip_minimum_file_size 1000 mod_gzip_maximum_file_size 100000 mod_gzip_maximum_inmem_size 60000 mod_gzip_min_http 1000 mod_gzip_handle_methods GET mod_gzip_item_include file \.html$ mod_gzip_item_include file \.jsp$ mod_gzip_item_include file \.do$ mod_gzip_item_include mime text/html mod_gzip_item_include mime text/plain mod_gzip_item_include mime application/x-javascript mod_gzip_item_include mime text/css mod_gzip_item_include mime text/xml mod_gzip_item_include …
Problem with openssl and Compiling Apache 2.2.11
Ursache ist, dass die Pfade richtig gesetzt werden müssen, damit ld den Parameter -lssl kennt. export LD_LIBRARY_PATH=”/www/hans/src/openssl-0.9.8j/” export LIBS=”-L/www/hans/src/openssl-0.9.8j” export CPPFLAGS=”-I/www/hans/src/openssl-0.9.8j/include/openssl” echo $LD_LIBRARY_PATH /www/jamba/src/openssl-0.9.8j/:/usr/lib/ echo $LIBS -L/www/jamba/src/openssl-0.9.8j echo $CPPFLAGS -I/www/jamba/src/openssl-0.9.8j/include/openssl
Issues on MaxClients Directive
WARNING: MaxClients of 3000 exceeds compile time limit of 2048 servers, lowering MaxClients to 2048. To increase, please see the HARD_SERVER_LIMIT define in src/include/httpd.h. Why increase MaxClients to 2048? Apache 1.x is non-threaded, so increasing MaxClients beyond 256 usually results in lower performance; often dramatically lower performance. At a prior job I worked with a …
setting Apache 2 ENVIRONMENT VARIABLES
in /etc/apache2/envvars # envvars-std – default environment variables for apachectl # # This file is generated from envvars-std.in # export APACHE_RUN_USER=www-data export APACHE_RUN_GROUP=www-data export APACHE_PID_FILE=/var/run/apache2.pid umask 002
GZIP Log Format
LogFormat “\”%h\” \”%{HOST}i\” \”%u\” \”%t\” \”%r\” \”%>s\” \”%b\” \”%{Referer}i\” \”%{User-Agent}i\” \”%{Connection}i\” \”%{Connection}o\” \”%{Content-Type}o\” \”%T\” \”PID:%P\” \”%{mod_gzip_result}n\” \”%{mod_gzip_input_size}n\” \”%{mod_gzip_output_size}n\” \”%{mod_gzip_compression_ration}n\”” JAMBA_BASIS_LOGFORMAT_GZIP
Using mod_cband to limit bandwidth per vhost
mod_cband (http://cband.linux.pl) can do this from 0.9.6.0 version! You should use CBandExceededSpeed directive to slow down pages when the bandwidth is exceeded 🙂 See: http://www.howtoforge.com/mod_cband_apache2_bandwidth_quota_throttling http://www.icewalkers.com/Linux/Software/524590/mod_cband.html http://www.montanalinux.org/mod_cband.html http://www.uno-code.com/?q=node/64
SSL error solution
If an SSL error goes like this: In Browser: (Error code: ssl_error_rx_record_too_long) or in log file: [error] [client 81.19.201.7] Invalid method in request \\x16\\x03\\x01 Solution: Include the following directive in vhost: SSLEngine on That was it . 😉
MPM ‘worker’ configuration (Apache2)
Directive Description Default (worker.MPM) ===================== =============================================================================== ==================== ListenBackLog Maximum length of the queue of pending connections 511 . MaxClients Global maximum number of connections that will be processed simultaneously 400 MaxClients SHOULD NOT be lower than (ServerLimit) x (ThreadsPerChild). Normally they should be equal. . ServerLimit Upper limit on configurable number of processes (children) 16 …