Re: Apache - bandwidth usage limit per vhost

2010-03-11 Thread Ozgur Kazancci
Mr. Coppa,
Thank you very much for the patch.

It compiles without any error and it works ok but I've noticed that if the 
mod_throttle is loaded, apache doesn't want to restart with 'apachectl restart' 
anymore. You should manually 'apachectl stop' and 'apachectl start' it;

A demonstration:

# apachectl start
/usr/sbin/apachectl start: httpd started
# apachectl restart
/usr/sbin/apachectl restart: httpd restarted -- (httpd stopped but did not 
start again)
# apachectl stop
/usr/sbin/apachectl stop: httpd (pid 947?) not running 

# apachectl start
/usr/sbin/apachectl start: httpd started

Do you have any suggestions?

Kind Regards.

---
Ozgur Kazancci



Re: Apache - bandwidth usage limit per vhost

2010-03-11 Thread Ozgur Kazancci
Oh, my mistake.. I forgot that it was a jailed httpd.

There was a File Not Found: /usr/lib/apache/modules/mod_throttle.so message 
in the error_log, but the file was already there (out of chroot path). So, I 
copied the mod_throttle.so file into /var/www/conf/modules and changed the path 
of LoadModule throttle_module in httpd.conf.

'apachectl restart' is working again.

Thanks.

// Ozgur



Re: Apache - bandwidth usage limit per vhost

2010-03-11 Thread Ted Roby
On Thu, Mar 11, 2010 at 6:17 AM, Ozgur Kazancci
ozgur.kazan...@info.uvt.rowrote:

 Oh, my mistake.. I forgot that it was a jailed httpd.

 There was a File Not Found: /usr/lib/apache/modules/mod_throttle.so
 message in the error_log, but the file was already there (out of chroot
 path). So, I copied the mod_throttle.so file into /var/www/conf/modules and
 changed the path of LoadModule throttle_module in httpd.conf.

 'apachectl restart' is working again.

 Thanks.

 // Ozgur


Just curious..   did 'apachectl graceful' tell you anything about that
missing file when testing?
That's my first and favorite debug command for apache esp. in production
env.



Re: Apache - bandwidth usage limit per vhost

2010-03-11 Thread Ted Roby
On Thu, Mar 11, 2010 at 10:17 AM, Ted Roby ted.r...@gmail.com wrote:



 On Thu, Mar 11, 2010 at 6:17 AM, Ozgur Kazancci 
 ozgur.kazan...@info.uvt.ro wrote:

 Oh, my mistake.. I forgot that it was a jailed httpd.

 There was a File Not Found: /usr/lib/apache/modules/mod_throttle.so
 message in the error_log, but the file was already there (out of chroot
 path). So, I copied the mod_throttle.so file into /var/www/conf/modules and
 changed the path of LoadModule throttle_module in httpd.conf.

 'apachectl restart' is working again.

 Thanks.

 // Ozgur


 Just curious..   did 'apachectl graceful' tell you anything about that
 missing file when testing?
 That's my first and favorite debug command for apache esp. in production
 env.



Sorry!!  I meant to ask about 'apachectl configtest'. THAT is my
favorite



Re: Apache - bandwidth usage limit per vhost

2010-03-11 Thread Ozgur Kazancci
 Just curious..   did 'apachectl graceful' tell you anything about that
missing file when testing?
--

No, 'apachectl graceful' did not give any error.



Re: Apache - bandwidth usage limit per vhost

2010-03-11 Thread Ozgur Kazancci
  Just curious..   did 'apachectl graceful' tell you anything about that
  missing file when testing?
  That's my first and favorite debug command for apache esp. in production
  env.
 
 
 
 Sorry!!  I meant to ask about 'apachectl configtest'. THAT is my
 favorite
--
No error.

# apachectl configtest
Processing config directory: /var/www/conf/modules/*.conf
 Processing config file: /var/www/conf/modules/host.conf
Syntax OK



Re: Apache - bandwidth usage limit per vhost

2010-03-10 Thread David Coppa
On Wed, 10 Mar 2010, Ozgur Kazancci wrote:


 Any ideas for structure has no member named `sin_addr' error? 

Can you try the following patch?

cheers,
David

--- mod_throttle.c.orig Sun Dec  3 11:15:10 2000
+++ mod_throttle.c  Wed Mar 10 16:52:55 2010
@@ -719,7 +719,7 @@
 #include sys/ipc.h
 #include sys/sem.h
 
-#if (defined(__GNU_LIBRARY__)  (!defined(_SEM_SEMUN_UNDEFINED))) || 
defined(__FreeBSD__) || defined(__NetBSD__)
+#if (defined(__GNU_LIBRARY__)  (!defined(_SEM_SEMUN_UNDEFINED))) || 
defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
 /* union semun is defined by including sys/sem.h */
 #else
 /* X/OPEN says we have to define it ourselves (twits). */
@@ -2811,7 +2811,7 @@
 * which we will apply the global policy for client connections.
 */
client_ip_config.track = (t_throttle *) get_client_ip(
-   client_ip_pool, r-connection-remote_addr.sin_addr
+   client_ip_pool, ((struct sockaddr_in 
*)r-connection-remote_addr)-sin_addr
);
 
/* Is it time for the period adjustment? */
@@ -3185,7 +3185,7 @@
(void) critical_acquire(critical);
 
 #ifdef THROTTLE_CLIENT_IP
-   client_ip = get_client_ip(client_ip_pool, 
r-connection-remote_addr.sin_addr);
+   client_ip = get_client_ip(client_ip_pool, ((struct sockaddr_in 
*)r-connection-remote_addr)-sin_addr);
 #endif
 #ifdef THROTTLE_REMOTE_USER
remote_user = get_remote_user(remote_user_pool, r-connection-user);



Re: Apache - bandwidth usage limit per vhost

2010-03-10 Thread Joachim Schipper
On Tue, Mar 09, 2010 at 06:20:36PM +, Gaby Vanhegan wrote:
 On 9 Mar 2010, at 17:42, Ozgur Kazancci wrote:
 
  Apache doesn't come with such a feature. I tried mod_cband. It was quite
  unstable, has too many bugs, issues. (Dozens of unfixed security
  issues, bugs since few years:
 http://sourceforge.net/tracker/?group_id=154335atid=791368
  ), there is no more development for that module and it is abandoned
  by its developer. I tried some other modules such as mod_bandwidth,
  mod_curb, mod_bw, but no luck. Pretty old and 'expired' modules.
 
 Thinking about this a little more, you could perhaps create a LogFormat string
 that dumped the hostname, bytes in and out to a logfile somewhere.  This could
 then be parsed every 5 minutes or so by a cron job, stats tabulated and Apache
 configs adjusted accordingly.
 
 You could then perhaps have a RewriteRule and use a RewriteMap to match
 specific hostnames that need redirecting to the bandwidth reached page.
 When a host hits it's bandwidth limit then an entry is created in the map and
 that site gets redirected to the holding page.
 
 Just a vague idea, probably full of holes but it could be a step in the right
 direction.

In fact, this information is contained in /var/www/logs/access_log in
the default configuration (the last field is the number of bytes in the
response, not including headers).

This should be doable with a cron script.

Joachim



Apache - bandwidth usage limit per vhost

2010-03-09 Thread Ozgur Kazancci
Hello everyone,

I'd like to set a (monthly) bandwidth quota limit to my Apache virtualhosts.
For instance, domain.com would have an amount of 10G/Month bandwidth limit
(and in case of exceeding the limit, it'd get redirected to a Bandwidth limit
exceeded alert page.)

Apache doesn't come with such a feature. I tried mod_cband. It was quite
unstable, has too many bugs, issues. (Dozens of unfixed security issues, bugs
since few years: http://sourceforge.net/tracker/?group_id=154335atid=791368
), there is no more development for that module and it is abandoned by its
developer. I tried some other modules such as mod_bandwidth, mod_curb, mod_bw,
but no luck. Pretty old and 'expired' modules.

Neither using PF w/ ALTQ helped, because I'm using name-based virtual hosts.
(Multiple domains on a single shared IP address).

The system is OpenBSD 4.6 with Apache 1.3 (the default chroot'd one).

Any advice would be greatly appreciated.
Thanks in advance.
Kind Regards.

--
CzgCr KazanC'C'D1
Faculty of Mathematics  Computer Science,
The West University of Timisoara / Romania.



Re: Apache - bandwidth usage limit per vhost

2010-03-09 Thread Gaby Vanhegan
On 9 Mar 2010, at 17:42, Ozgur Kazancci wrote:

 I'd like to set a (monthly) bandwidth quota limit to my Apache
virtualhosts.
 For instance, domain.com would have an amount of 10G/Month bandwidth limit
 (and in case of exceeding the limit, it'd get redirected to a Bandwidth
limit
 exceeded alert page.)

I too would be very interested in something that works with the stock Apache
in 4.6.

Gaby.

--
Imagine there were no hypothetical situations.
http://playr.co.uk/



Re: Apache - bandwidth usage limit per vhost

2010-03-09 Thread Gaby Vanhegan
On 9 Mar 2010, at 17:42, Ozgur Kazancci wrote:

 Apache doesn't come with such a feature. I tried mod_cband. It was quite
 unstable, has too many bugs, issues. (Dozens of unfixed security issues,
bugs
 since few years:
http://sourceforge.net/tracker/?group_id=154335atid=791368
 ), there is no more development for that module and it is abandoned by its
 developer. I tried some other modules such as mod_bandwidth, mod_curb,
mod_bw,
 but no luck. Pretty old and 'expired' modules.


Thinking about this a little more, you could perhaps create a LogFormat string
that dumped the hostname, bytes in and out to a logfile somewhere.  This could
then be parsed every 5 minutes or so by a cron job, stats tabulated and Apache
configs adjusted accordingly.

You could then perhaps have a RewriteRule and use a RewriteMap to match
specific hostnames that need redirecting to the bandwidth reached page.
When a host hits it's bandwidth limit then an entry is created in the map and
that site gets redirected to the holding page.

Just a vague idea, probably full of holes but it could be a step in the right
direction.

G.

--
Being drunk is feeling sophisticated without being able to say it.
http://www.playr.co.uk/



Re: Apache - bandwidth usage limit per vhost

2010-03-09 Thread Marcos Laufer
 On 9 Mar 2010, at 17:42, Ozgur Kazancci wrote:

   
 I'd like to set a (monthly) bandwidth quota limit to my Apache virtualhosts.
 
 For instance, domain.com would have an amount of 10G/Month bandwidth limit
 (and in case of exceeding the limit, it'd get redirected to a Bandwidth 
 limit exceeded alert page.)
 

 I too would be very interested in something that works with the stock Apache
 in 4.6.

 Gaby.

 --
 Imagine there were no hypothetical situations.
 http://playr.co.uk/
   

Then what you need is exactly mod_throttle.
mod_throttle project is discontinued but the latest version works just 
fine and does it job very well.
I use it with stock Apache since OpenBSD 3.4 and never had problems with it.

Regards,

Marcos Laufer
* marcos mailto:mar...@ipversion4.com@ipversion4.com 
mailto:mar...@ipversion4.com
CTO

Ipversion4.com
http://www.ipversion4.com http://www.ipversion4.com/
( 0800-444-HOSTING
Rodriguez Peqa 468 1 C



Re: Apache - bandwidth usage limit per vhost

2010-03-09 Thread Ozgur Kazancci
Thanks a lot for the suggestions.

 Then what you need is exactly mod_throttle.
 mod_throttle project is discontinued but the latest version works just fine 
 and does it job very well.
 I use it with stock Apache since OpenBSD 3.4 and never had problems with it.

Could you tell me the version of your mod_throttle, please? I've downloaded the 
3.1.2 one (mod_throttle312.tgz), tried to compile, but got the following errors:

mod_throttle.c:726: error: redefinition of `union semun'
mod_throttle.c: In function `access_handler':
mod_throttle.c:2814: error: structure has no member named `sin_addr'
mod_throttle.c: In function `log_handler':
mod_throttle.c:3188: error: structure has no member named `sin_addr'
apxs:Break: Command failed with rc=1
*** Error code 1

Stop in /root/mod_throttle-3.1.2 (line 24 of Makefile).

Then, I opened the mod_throttle.c file and changed the following line:
defined(__FreeBSD__) || defined(__NetBSD__)
with
defined(__FreeBSD__) || defined(__NetBSD__)  || defined(__OpenBSD__)

 compiled it again. The first error (redefinition of union semun) did not 
appear anymore. The others remained and i couldn't go more far..

Any ideas for structure has no member named `sin_addr' error? 

Many thanks,
Best Regards.

// Ozgur Kazancci