diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | mod_bw-httpd24.patch | 42 | ||||
-rw-r--r-- | mod_bw.conf | 196 | ||||
-rw-r--r-- | mod_bw.spec | 88 |
4 files changed, 330 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1e65467 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../common/Makefile + diff --git a/mod_bw-httpd24.patch b/mod_bw-httpd24.patch new file mode 100644 index 0000000..d49d310 --- /dev/null +++ b/mod_bw-httpd24.patch @@ -0,0 +1,42 @@ +diff -up mod_bw/mod_bw.c.httpd24 mod_bw/mod_bw.c +--- mod_bw/mod_bw.c.httpd24 2012-04-10 11:57:06.092958430 +0200 ++++ mod_bw/mod_bw.c 2012-04-10 11:59:51.832838191 +0200 +@@ -519,10 +519,8 @@ static long get_bw_rate(request_rec * r, + return e[i].rate; + + case T_IP: +- if (apr_ipsubnet_test(e[i].x.ip, r->connection->remote_addr)) { +- return e[i].rate; +- } +- break; ++ return e[i].rate; ++ + case T_HOST: + if (!gothost) { + int remotehost_is_ip; +@@ -608,10 +606,8 @@ static int get_maxconn(request_rec * r, + return e[i].max; + + case T_IP: +- if (apr_ipsubnet_test(e[i].x.ip, r->connection->remote_addr)) { +- return e[i].max; +- } +- break; ++ return e[i].max; ++ + case T_HOST: + if (!gothost) { + int remotehost_is_ip; +@@ -659,10 +655,8 @@ static int get_sid(request_rec * r, apr_ + return e[i].sid; + + case T_IP: +- if (apr_ipsubnet_test(e[i].x.ip, r->connection->remote_addr)) { +- return e[i].sid; +- } +- break; ++ return e[i].sid; ++ + case T_HOST: + if (!gothost) { + int remotehost_is_ip; diff --git a/mod_bw.conf b/mod_bw.conf new file mode 100644 index 0000000..dea80d4 --- /dev/null +++ b/mod_bw.conf @@ -0,0 +1,196 @@ +<IfDefine HAVE_BW> + <IfModule !mod_bw.c> + LoadModule bw_module extramodules/mod_bw.so + </IfModule> +</IfDefine> + +<IfModule mod_bw.c> + +# You need to set this to On, for the mod to work.. By default, the mod is +# disabled, and wont limit anything. +# +# Example : +# BandWidthModule On +# +# BandWidthModule [On|Off] + +BandWidthModule On + +# When enabled (disabled by default) the log will output lots of data to the +# error log. This data is for debugging purposes, and is usually not needed. +# If you are curious, you can enable. Please note, that this will make your +# logs grow a LOT. +# +# Example : +# BandWidthDebug On +# +# BandWidthDebug [On|Off] + +# By default, the mod will catch every request. This was done because it is +# easier to configure. +# if you disable it, you will have to add the output filter by hand. This is +# useful is you want only some request being processed by bw_mod. +# +# Example : +# ForceBandWidthModule Off +# AddOutputFilterByType BW_MOD text/html text/plain +# +# ForceBandWidthModule [On|Off] + +# This takes 2 parameters. From is the origin of the connections. It could +# be a full host, part of a domain, an ip address, a network mask (i.e +# 192.168.0.0/24 or 192.168.0.0/255.255.255.0) or all. +# The second parameter indicates the total speed available to the Origin. +# If speed is 0, there is no limit. +# +# Example : +# BandWidth localhost 10240 +# BandWidth 192.168.218.5 0 +# +# ( Order is relevant. First entries have precedence ) +# +# BandWidth [From] [bytes/s] + +# This takes 2 parameters. From is the origin of the connections. It could +# be a full host, part of a domain, an ip address, a network mask (i.e +# 192.168.0.0/24 or 192.168.0.0/255.255.255.0) or all. +# The second parameter indicates the minimun speed each client will have. +# What does this mean ? If you have a total of 100kbytes speed, and you put +# MinBandWidth at 50kbytes, it doesnt matter how many clients you have, all +# of them will have at minimun 50kbytes of total speed to download. +# If speed is 0, you will be using the default minimun (256 bytes/s). +# There is a special value of -1. This value means that each client, will +# have a top speed determined by the BandWidth directive. See the examples. +# +# Examples : +# BandWidth all 102400 +# MinBandWidth all 50000 +# +# The example above, will have a top speed of 100kb for the 1° +# client. If more clients come, it will be splitted accordingly but +# everyone will have at least 50kb (even if you have 50 clients) +# +# BandWidth all 50000 +# MinBandWidth all -1 +# +# This example, makes everyone have 50kb as top speed. +# +# MinBandWidth [From] [bytes/s] + +# Type, is the last part of a file, or * for all. You can use .tgz to match +# only tar-compressed files, .avi to match video files, or * to match all. +# Minimum Size, is the size (in kbytes) of the file, to be matched. That way +# you can match huge video files that hog your bandwidth. +# The last parameter... is obvious. The speed allowed. +# +# Example : +# LargeFileLimit .avi 500 10240 +# +# This limits .avi files over (or equal to) 500kb to 10kbytes/s +# +# LargeFileLimit [Type] [Minimum Size] [bytes/s] + +# Probably you never need to touch this. It defaults to 8192 which is good +# for almost any speed. +# It must be a size between 1024 and 131072. A Small packet will cause the +# top speed to be lower, and the mod using more time splitting. If you use +# a Size too big, the mod will adjust it to lower speeds. +# +# BandWidthPacket [Size] + +# This directives is useful to deliver a personalized error code. +# At default, when maxconnections is reached, the mod will issue a 503 +# HTTP_SERVICE_UNAVAILABLE code. For some users, it is annoying to have an +# error message, and dont knowing why. You could use an ErrorDocument to +# point error 503 to a page explaining that you are under a heavy load of +# connections, but sometimes 503 isn't issued by the mod. +# So, with this directive, you can set the error code to return when +# maxconnections is reached. You can use any error code between 300 and 599. +# Please note, that some of the error codes are already used, so before using +# any number, take a look to a list of the codes (search for http error codes +# in google). +# When testing, i've used the error code 510, which hasn't been defined yet. +# +# And Example, with Personalized Error Page : +# +# ErrorDocument 510 /errors/maxconexceeded.html +# BandWidthError 510 +# +# Note : Sometimes, the personalized page didn't appear. I'm not sure, but +# in many cases, it got fixed, by making the page size over 1024bytes. +# Anyways, if you need help using ErrorDocument, refer to the apache +# Documentation. +# +# BandWidthError [Error] + +# This takes 2 parameters. From is the origin of the connections. It could +# be a full host, part of a domain, an ip address, a network mask (i.e +# 192.168.0.0/24 or 192.168.0.0/255.255.255.0) or all. +# The second parameter, is the max connections allowed from the origin. Any +# connection over Max, will get a 503 Service Temporarily Unavailable +# +# There is a catch. You NEED to have a BandWidth limit for the same origin. +# It doesnt need to be a low limit. You can use an unlimited setting. +# You might wonder why. It's because im using them same memory space of the +# bandwidth limit, to count the connections, so i can save memory space. +# If you dont put a BandWidth using the same origin, MaxConnections will be +# ignored. +# +# Example : +# BandWidth all 0 +# MaxConnection all 20 +# or +# BandWidth all 0 +# BandWidth 192.168.0.0/24 10240 +# MaxConnection all 20 +# MaxConnection 192.168.0.0/24 5 +# +# +# Please, rememeber that every speed, will depend mostly on your connection. +# You cant get more speed if you dont have it. +# +# Remember also.. if you dont follow the instructions, and get some weird +# results, recheck your config before sending me an email. +# +# MaxConnection [From] [Max] + +# <VirtualHost *> +# BandWidthModule On +# BandWidth all 16384 +# LargeFileLimit * 500 4096 +# <Directory /> +# LargeFileLimit * 100 1024 +# </Directory> +# </VirtualHost> +# +# This wont limit Directory / to 16384. The Directory wont "inherit" the +# settings from the vhost if you use some of the mod's directives. + +</IfModule> + +# VirtualHost example with bandwidth limitation: +# For more information, look at bw_mod documentation. +# In this example, we restrict the bandwidth to 10kb +# for the connections coming from localhost. +# And we set the bandwidth unlimited for any other +# connections. +# We set maximum amount of concurrent connections as 40. +# When the bandwidth is exceeded, the visitors see the +# personalized error code no 510. +# +#<VirtualHost *> +# ServerAdmin webmaster@dummy-host.example.com +# DocumentRoot /www/docs/dummy-host.example.com +# ServerName dummy-host.example.com +# ErrorLog logs/dummy-host.example.com-error_log +# CustomLog logs/dummy-host.example.com-access_log common +# <IfModule mod_bw.c> +# BandWidthModule On +# BandWidthDebug Off +# BandWidth localhost 10240 +# BandWidth all 0 +# MaxConnection all 40 +# BandWidthError 510 +# </IfModule> +#</VirtualHost> + diff --git a/mod_bw.spec b/mod_bw.spec new file mode 100644 index 0000000..fb9cb1d --- /dev/null +++ b/mod_bw.spec @@ -0,0 +1,88 @@ +%{!?_httpd_mmn: %{expand: %%global _httpd_mmn %%(cat %{_includedir}/httpd/.mmn || echo missing-httpd-devel)}} +%{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_sbindir}/apxs}} + +Name: mod_bw +Version: 0.92 +Release: 2%{?dist} +Summary: Bandwidth Limiter For Apache + +Group: System Environment/Daemons +License: ASL 2.0 +URL: http://www.ivn.cl/apache +Source0: http://www.ivn.cl/apache/files/source/mod_bw-%{version}.tgz +Source1: mod_bw.conf +Patch0: mod_bw-httpd24.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: httpd-devel +Requires: httpd-mmn = %{_httpd_mmn} + +%description +mod_bw is a bandwidth administration module for Apache httpd 2.x + +* Restricts the number of simultaneous connections per vhost/dir +* Limits the bandwidth for files on vhost/dir + +%prep +%setup -q -c + +%patch0 -p1 -b .httpd24 + +mv mod_bw.txt mod_bw.txt.iso8859 +iconv -f ISO-8859-1 -t UTF-8 mod_bw.txt.iso8859 > mod_bw.txt + + +%build +%{_httpd_apxs} -Wc,"%{optflags}" -c mod_bw.c + + +%install +rm -rf $RPM_BUILD_ROOT +install -Dpm 755 .libs/mod_bw.so \ + $RPM_BUILD_ROOT%{_libdir}/httpd/modules/mod_bw.so +install -Dpm 644 %{SOURCE1} \ + $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/mod_bw.conf + + +%clean +rm -rf $RPM_BUILD_ROOT + + +%files +%defattr(-,root,root,-) +%doc ChangeLog LICENSE TODO mod_bw.txt +%config(noreplace) %{_sysconfdir}/httpd/conf.d/mod_bw.conf +%{_libdir}/httpd/modules/mod_bw.so + + +%changelog +* Wed Apr 18 2012 Remi Collet <RPMS@FamilleCollet.com> - 0.92-2 +- sync patch with rawhide (but keep version 0.92) + +* Tue Apr 10 2012 - Jakub Hrozek <jhrozek@redhat.com> 0.8-8 +- Fix compilation with httpd-2.4 (Jan Kaluza <jkaluza@redhat.com>) +- Provide backwards-compatible _httpd_apxs macro + +* Sun Apr 01 2012 Remi Collet <RPMS@FamilleCollet.com> - 0.92-1 +- update to 0.92 for remi repo and httpd 2.4 + +* Wed Mar 14 2012 Jakub Hrozek <jhrozek@redhat.com> - 0.8-7 +- Do not require httpd itself + +* Wed Mar 14 2012 Jakub Hrozek <jhrozek@redhat.com> - 0.8-6 +- Require httpd-mmn (#803067) + +* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Mon Feb 18 2008 Jakub Hrozek <jhrozek@redhat.com> - 0.8-1 +- initial packaging |