Re: Apache 1.3 mass virtual hosting recipe

2004-09-21 Thread Fraser Campbell
Hi,

I finally got around to trying out mod_rewrite and it looks like things will 
work exactly as I'd hoped.  I'm posting this recipe since I was unable to 
find a documented example of how to do it and I figured lots of people might 
be interested in doing it.  It does need some more testing but at this point 
I see no reason why it will not work.

The basic concept is to create a directory and have apache serve it 
automatically under the correct domain name (zero config apache). Let's say I 
want to have wehave.net and www.wehave.net hosted on my server.  I could 
create a VirtualHost with "ServerName wehave.net" and "ServerAlias 
www.wehave.net" or I could do this:

  RewriteEngine on
  RewriteLog /tmp/junk
  RewriteLogLevel 9
  RewriteMap  vhosts-map  prg:/usr/local/sbin/vhost-redirector.pl
  RewriteRule ^/(.*)$ ${vhosts-map:%{HTTP_HOST}}$1

My perl script looks like this:

  #!/usr/bin/perl -wT
  use strict;
  $| = 1;
  while (<>) {
# FIXME, do we need to do syntax checking on hostname?
chomp;
my @path = split(/\./, $_);
while ( ! -d '/var/www/' . join('/', reverse(@path)) . '/web/' and @path){
  shift @path;
}
if (@path) {
  print '/var/www/' . join('/', reverse(@path)) . "/web/\n";
} else {
  print "/var/www/web/\n";
}
  }

The end result is that once dns points something at your server simply 
creating the appropriate directory heirarchy is enough to host a given 
website (and aliases).  Given the previous example (hosting wehave.net), I 
would create the directory /var/www/net/wehave/web and 
http://wehave.net/whatever would translate to the filesystem 
as /var/www/net/wehave/web/whatever ... requests for 
http://www.wehave.net/whatever would translate to the same file unless I 
wanted to serve something different for that in which case I would just need 
to create /var/www/net/wehave/www/web/whatever 

If I want www.wehave.ca to be the same as wehave.net then I just link ...
ln -s /var/www/net/wehave /var/www/ca/wehave

Any site pointed to your server which doesn't have an appropriate config would 
end up directed to the filesystem directory /var/www/web ... there could be a 
default page there stating "Site not configured".

One thing I haven't shown in my example is that you would have to either not 
rewrite shared paths (such as /icons/, /squirrelmail/, etc.) or you would 
have to hardcode those paths into the perl script.

The perl code starts when apache starts and stays resident so the extra 
overhead is minimal (I am guessing) i.e. you are not firing up a perl process 
for every single request.

Obviously under this scheme all hostnames get treated the same, you would have 
to override the defaults in some cases (SSL sites for example) but that can 
be done by adding normal rules in  or  containers.

On September 5, 2004 09:06 pm, Fraser Campbell wrote:
> Hi,
>
> I'm setting up a new server and would like to use mod_vhost_alias, or other
> mass virtual hosting method, if possible.  mod_vhost_alias is very simple
> to setup and works as advertised:
>
> LoadModule vhost_alias_module /usr/lib/apache/1.3/mod_vhost_alias.so
> UseCanonicalName Off
> VirtualDocumentRoot /var/www/%0/web
>
> Unfortunately, it is as simple as it is simple to setup ;-)  My question is
> in regards to ServerAlias.  "Normal" clients host their website at
> http://www.abcd.com/ but they (and I) also like it when http://abcd.com/
> works as well.  Is there any way (besides filesystem link) to make
> vhost_alias find the right DocumentRoot?
>
> Ideally I'd like a directory structure like this:
>
> /var/www/com/abcd/web/
> /var/www/com/abcd/subdomain/web/
>
> When serving http://www.abcd.com/ apache wouldn't
> find /var/www/com/abcd/www/web/ so it would fallback
> to /var/www/com/abcd/web/, if that were missing it would fallback
> to /var/www/com/web/ and then to /var/www/web/
>
> Perhaps something like the above is possible using mod_rewrite???  I'll
> keep plugging away for a while but if anyone knows the answer I'm all for
> shortcuts.
>
> Second question.  Supposing that the above can work somehow I'd like to use
> one common logfile for all virtualhosts, with the virtualhost's name
> prepended to each log line.  This is easy of course.  The catch of course
> is that I'd like to have consistent names for hosts, i.e. I don't want to
> be splitting off logfiles for www.abcd.com and abcd.com when those are
> actually the same site.
>
> Basically, I'd like apache logging to be smart enough to realize that it is
> actually serving abcd.com although the hostname in the request was
> www.abcd.com.
>
> --
> Fraser Campbell <[EMAIL PROTECTED]> http://www.wehave.net/
> Georgetown, Ontario, Canada   Debian GNU/Linux


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



ulimit shows no effect

2004-09-21 Thread Michael Kreilmeier
Hi,
I'm running a debian sarge server with a few Zope-instances. A known 
issue with Zope is, that it is very RAM demanding. Anyways, what I want 
to do is to limit the physical memory my Zope processes can use. Some 
people are doing this with DJB's daemontools. If possible, I'd like 
*not* to use daemontools. I thought ulimit could do the same thing for 
me - seems that I was wrong or I'm doing something wrong.

I tried to set a memory limit in
/etc/security/limit.conf:
zope  hardrss 65536
I tried to set a memory limit in
/etc/profile:
ulimit -m 65536
I tried to set ulimit in the Zope startup script:
#!/bin/sh
ulimit -m 65536
exec "/path/to/runzope"
All the above setups should, at least to my understanding, set a limit 
of 64 MB. I didn't get any positive results when running a test below.

Test:
* start zope
* watch memory usage with top
* make zope use much memory, i.e. up-/download a large file
* watch the process bypass the memory limit with top
What am I doing wrong. It's probably obvious, but I'm somehow stuck.
Thanks,
Michael
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


gateway-tc-nat-iptables-userstats - v 2

2004-09-21 Thread Konstantin Kostadinov
That's it, it's work ;)

I donwload this : 
http://freshmeat.net/projects/linux-qnet/?branch_id=51402&release_id=169937

and now i have all that i need - 
 - iptables patch-o-matic-ng for limiting connections per ip
 - iptables-p2p - now i can cut p2p in work time
 - and the imporant thing esfq, and wrr

I use out old scripts : 

 - iptables scripts 
- INPUT,OUTPUT,FORWARD chains, connections limit per ip, packet mark for 
international/peering traffic 

- tc script based on htb/wrr with class for every internal ip, classes for 
priority international, prioriry peering, class for out provider servers unshaped / 
80MBs, and HTB for outgoing traffic, class for insite servers - mail,dns,web

- auto nat-ing scrpit for adding internal hosts for useing i-net service based 
on dns,wins,smb,ping lookup

- web statistic script with international/peering traffic per ip and 
additional statistic with wipl-daemon package.


After few weeks i'll publish all conf files and scripts for use.

And my old decision for rebuilding the machine was kernels 2.4.22, 2.4.26 Oops-ing 
because many WRR-classes ;), but now with 2.6.8.1 i think the prbolem is gone.
 
That's it, Debian/GNU Linux RULEZ !

-- 

Konstantin Kostadinov

Public PGP : http://www.fadata.bg/pgp/konstantinpgp.asc
---

Q:  What is printed on the bottom of beer bottles in Minnesota?
A:  Open other end.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]