httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Yardley <apache-us...@veggiechinese.net>
Subject [users@httpd] mod_rewrite troubles
Date Tue, 28 Jan 2003 21:16:51 GMT
I've been having problems with our shared hosting customers and
mod_rewrite.  While I realize that it's easy to write inefficient
mod_rewrite rules, I've seen some of these take down a server (even a
pretty buff one - i386 with dual 2.something processors and a GB of
ram).

Apache 1.3.27 on Debian Linux 2.2 and 3.0 (with openwall kernel patches,
including restricted access to /proc for users, if it matters); mostly
kernels 2.2.x; mostly 2.2.23.

soy: 01:08pm# /dh/apache/template/bin/httpd -V
Server version: Apache/1.3.27 (Unix)
Server built:   Dec 12 2002 16:16:54
Server's Module Magic Number: 19990320:13
Server compiled with....
 -D EAPI
 -D HAVE_MMAP
 -D HAVE_SHMGET
 -D USE_SHMGET_SCOREBOARD
 -D USE_MMAP_FILES
 -D HAVE_FCNTL_SERIALIZED_ACCEPT
 -D HAVE_SYSVSEM_SERIALIZED_ACCEPT
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D HARD_SERVER_LIMIT=512
 -D SHARED_CORE
 -D HTTPD_ROOT="/usr/local/dh/apache/template"
 -D SUEXEC_BIN="/usr/local/dh/apache/template/bin/suexec"
 -D SHARED_CORE_DIR="/usr/local/dh/apache/template/libexec"
 -D DEFAULT_PIDLOG="/usr/local/dh/apache/logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="/usr/local/dh/apache/logs/httpd.scoreboard"
 -D DEFAULT_LOCKFILE="/usr/local/dh/apache/logs/httpd.lock"
 -D DEFAULT_ERRORLOG="/usr/local/dh/apache/logs/error_log"
 -D TYPES_CONFIG_FILE="etc/mime.types"
 -D SERVER_CONFIG_FILE="etc/httpd.conf"
 -D ACCESS_CONFIG_FILE="etc/access.conf"
 -D RESOURCE_CONFIG_FILE="etc/srm.conf"

mod_rewrite is being called by an .htaccess file.

Here are some examples:

[1]
RewriteEngine on
RewriteRule (.*).gif$ $1.gif [L]
RewriteRule ^(articles)/(.*)/(.*)$ /index.php?p=$1/$2/&f=$3 [L]

(obviously in this one it would probably be a good idea to escape the
period in ".gif").
 
[2]
RewriteEngine On
RewriteRule .* /sorry.html

What happens is that processes start getting "hung" (doing strace on the
PID hasn't turned up anything too interesting thus far). I realize that
part of the problem may be with the mod_rewrite rules, but it seems
unfortunate that a user can (accidentally or maliciously) take down a
whole machine with one mod_rewrite rule. We _are_ considering disabling
mod_rewrite entirely (by default at least), but this is obviously not an
ideal solution.

The end results range from extremely high loads on the machine to total
crash (if the problem isn't detected or fixed early enough). Commenting
out the offending lines in the (l)user's .htaccess file will always fix
the problem.

Example from top. If not noticed / killed quickly, the processes can
hang on for quite some time (they're not actually doing anything as far
as we can tell). In many cases they will take up a very large amount of
memory / CPU for quite some time.

28627 dhapache  11   0  138M  73M   596 R       0 28.0 14.6   4:31 libhttpd.ep
29849 dhapache   1   0  129M  55M   588 R       0 25.0 10.9   4:07 libhttpd.ep
26526 dhapache  14   0 85100  75M   556 R       0 21.9 14.9   2:38 libhttpd.ep
26529 dhapache   0   0 84264  74M   112 D       0 19.0 14.6   2:38 libhttpd.ep

In some cases, we've been able to limit the damage by starting Apache
with 'softlimit'  (from daemontools), which kills the processes after
they reach a certan amount of memory usage for a long period of time...
this is not an ideal long-term solution, though, and may have unintended
side effects.

Any suggestions on how to better troubleshoot this, patches, or other
information would be quite useful.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message