You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Nilesh Govindarajan <li...@itech7.com> on 2010/02/26 17:57:20 UTC

[users@httpd] Cacthing hosts

Hi,

I have two domains, example.net and example.com

*.example.net & *.example.com point to the server's IP (Wildcard CNAME).

Now only some subdomains like www, img, etc. are defined on both domains.

I want to catch all other subdomains not configured and raise a 404 error.

How to ?

-- 
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com

Re: [users@httpd] Cacthing hosts

Posted by Rich Bowen <rb...@rcbowen.com>.
On Feb 26, 2010, at 11:57 AM, Nilesh Govindarajan wrote:

> Hi,
> 
> I have two domains, example.net and example.com
> 
> *.example.net & *.example.com point to the server's IP (Wildcard CNAME).
> 
> Now only some subdomains like www, img, etc. are defined on both domains.
> 
> I want to catch all other subdomains not configured and raise a 404 error.
> 
> How to ?

You'll need two virtual hosts - one for the "good" hostnames, identified with ServerAlias directive(s). Another for everything else, identified with ServerAlias *.example.com



Re: [users@httpd] Cacthing hosts

Posted by Nilesh Govindarajan <li...@itech7.com>.
On Fri, Feb 26, 2010 at 10:42 PM, Tom Evans <te...@googlemail.com>wrote:

> On Fri, Feb 26, 2010 at 4:57 PM, Nilesh Govindarajan <li...@itech7.com>
> wrote:
> > Hi,
> >
> > I have two domains, example.net and example.com
> >
> > *.example.net & *.example.com point to the server's IP (Wildcard CNAME).
> >
> > Now only some subdomains like www, img, etc. are defined on both domains.
> >
> > I want to catch all other subdomains not configured and raise a 404
> error.
> >
> > How to ?
> >
> > --
> > Nilesh Govindarajan
> > Site & Server Administrator
> > www.itech7.com
> >
> >
>
> I don't know about 404, but you can have them raise a 403 easily enough:
>
> <VirtualHost *:80>
>  ServerName www.example.com
> </VirtualHost>
>
> <VirtualHost *:80>
>  ServerName *.example.com
>  RewriteEngine On
>  RewriteRule ^ - [F]
> </VirtualHost>
>
> Cheers
>
> Tom
>
> ---------------------------------------------------------------------
> 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
>
>
Thanks all. Got it.

-- 
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com

Re: [users@httpd] memory problems, I lose control of the entire server

Posted by Tom Evans <te...@googlemail.com>.
On Sun, Feb 28, 2010 at 5:24 PM, Alvise Nicoletti
<li...@alvisenicoletti.com> wrote:
> Hi.
> I searched help from several months ago with no success.
> So I'll repeat again my problem hoping that this time someone will answer.
>
> I often (3 times in a month) control of my virtual server, so I have to call
> the provider to soft-reset it.
> The problem is that apache takes all the memory and the cpu usage of the
> server, and sometimes after that I have also kernel panic errors.
>
> Even with the server working, I have the apache2 daemons big from 30 to 50
> megabytes each one (now I use 9).
>
>
> In the logs I found stuff like this:
> Feb 28 12:54:09 utopia kernel: [408986.594006] apache2 invoked oom-killer:
> gfp_mask=0x1201d2, order=0, oomkilladj=0
> Feb 28 12:54:09 utopia kernel: [408986.594022] Pid: 6817, comm: apache2 Not
> tainted 2.6.28-18-server #59-Ubuntu
> Feb 28 12:54:09 utopia kernel: [408986.594026] Call Trace:
> Feb 28 12:54:09 utopia kernel: [408986.594080]  [<ffffffff802b3825>]
> oom_kill_process+0x95/0x240
> Feb 28 12:54:09 utopia kernel: [408986.594087]  [<ffffffff802b3fdf>] ?
> select_bad_process+0xef/0x130
> Feb 28 12:54:09 utopia kernel: [408986.594091]  [<ffffffff802b40d4>]
> out_of_memory+0xb4/0x150
> Feb 28 12:54:09 utopia kernel: [408986.594095]  [<ffffffff802b6c49>]
> __alloc_pages_internal+0x4a9/0x4f0
> Feb 28 12:54:09 utopia kernel: [408986.594101]  [<ffffffff802b9a7a>]
> __do_page_cache_readahead+0xda/0x210
> Feb 28 12:54:09 utopia kernel: [408986.594105]  [<ffffffff802b9c0e>]
> do_page_cache_readahead+0x5e/0x90
> Feb 28 12:54:09 utopia kernel: [408986.594108]  [<ffffffff802b201a>]
> filemap_fault+0x34a/0x430
> Feb 28 12:54:09 utopia kernel: [408986.594113]  [<ffffffff802c6010>]
> __do_fault+0x50/0x520
> Feb 28 12:54:09 utopia kernel: [408986.594117]  [<ffffffff802c7199>]
> handle_mm_fault+0x1e9/0x470
> Feb 28 12:54:09 utopia kernel: [408986.594134]  [<ffffffff802f3a1f>] ?
> path_walk+0xbf/0xd0
> Feb 28 12:54:09 utopia kernel: [408986.594158]  [<ffffffff8022f669>] ?
> default_spin_lock_flags+0x9/0x10
> Feb 28 12:54:09 utopia kernel: [408986.594177]  [<ffffffff8069e0d7>]
> do_page_fault+0x307/0x780
> Feb 28 12:54:09 utopia kernel: [408986.594183]  [<ffffffff802eb9f3>] ?
> cp_new_stat+0xe3/0xf0
> Feb 28 12:54:09 utopia kernel: [408986.594186]  [<ffffffff802ebee6>] ?
> sys_newstat+0x36/0x50
> Feb 28 12:54:09 utopia kernel: [408986.594198]  [<ffffffff8069b6ba>]
> error_exit+0x0/0x70
> Feb 28 12:54:09 utopia kernel: [408986.594202] Mem-Info:
> Feb 28 12:54:09 utopia kernel: [408986.594205] DMA per-cpu:
> Feb 28 12:54:09 utopia kernel: [408986.594207] CPU    0: hi:    0, btch:   1
> usd:   0
> Feb 28 12:54:09 utopia kernel: [408986.594210] CPU    1: hi:    0, btch:   1
> usd:   0
> Feb 28 12:54:09 utopia kernel: [408986.594212] DMA32 per-cpu:
> Feb 28 12:54:09 utopia kernel: [408986.594214] CPU    0: hi:  186, btch:  31
> usd: 183
> Feb 28 12:54:09 utopia kernel: [408986.594216] CPU    1: hi:  186, btch:  31
> usd: 172
> Feb 28 12:54:09 utopia kernel: [408986.594226] Active_anon:363780
> active_file:19 inactive_anon:121250
> Feb 28 12:54:09 utopia kernel: [408986.594228]  inactive_file:91
> unevictable:0 dirty:0 writeback:0 unstable:0
> Feb 28 12:54:09 utopia kernel: [408986.594229]  free:3066 slab:4774 mapped:1
> pagetables:7473 bounce:0
> Feb 28 12:54:09 utopia kernel: [408986.594234] DMA free:6644kB min:12kB
> low:12kB high:16kB active_anon:0kB inactive_anon:0kB acti$
> Feb 28 12:54:09 utopia kernel: [408986.594237] lowmem_reserve[]: 0 2004 2004
> 2004
> Feb 28 12:54:09 utopia kernel: [408986.594244] DMA32 free:5620kB min:5720kB
> low:7148kB high:8580kB active_anon:1455120kB inactive$
> Feb 28 12:54:09 utopia kernel: [408986.594247] lowmem_reserve[]: 0 0 0 0
> Feb 28 12:54:09 utopia kernel: [408986.594259] DMA: 3*4kB 3*8kB 3*16kB
> 3*32kB 3*64kB 1*128kB 2*256kB 1*512kB 1*1024kB 0*2048kB 1*$
> Feb 28 12:54:09 utopia kernel: [408986.594272] DMA32: 155*4kB 1*8kB 0*16kB
> 0*32kB 0*64kB 1*128kB 1*256kB 1*512kB 0*1024kB 0*2048k$
> Feb 28 12:54:09 utopia kernel: [408986.594284] 828 total pagecache pages
> Feb 28 12:54:09 utopia kernel: [408986.594286] 0 pages in swap cache
> Feb 28 12:54:09 utopia kernel: [408986.594288] Swap cache stats: add 4551,
> delete 4551, find 160864/160937
> Feb 28 12:54:09 utopia kernel: [408986.594297] Free swap  = 0kB
> Feb 28 12:54:09 utopia kernel: [408986.594299] Total swap = 0kB
> Feb 28 12:54:09 utopia kernel: [408986.608274] 524272 pages RAM
> Feb 28 12:54:09 utopia kernel: [408986.608283] 15596 pages reserved
> Feb 28 12:54:09 utopia kernel: [408986.608284] 63040 pages shared
> Feb 28 12:54:09 utopia kernel: [408986.608286] 500299 pages non-shared
> Feb 28 12:54:09 utopia kernel: [408986.608292] Out of memory: kill process
> 6817 (apache2) score 63892 or a child
> Feb 28 12:54:09 utopia kernel: [408986.609426] Killed process 6817 (apache2)
> Feb 28 12:54:17 utopia kernel: [409094.110911] pickup invoked oom-killer:
> gfp_mask=0x1201d2, order=0, oomkilladj=0
> Feb 28 12:54:17 utopia kernel: [409094.110925] Pid: 5668, comm: pickup Not
> tainted 2.6.28-18-server #59-Ubuntu
> Feb 28 12:54:17 utopia kernel: [409094.110929] Call Trace:
> (and so on)
>
> This is my configuration:
> Linux utopia 2.6.28-18-server #59-Ubuntu SMP Thu Jan 28 02:25:03 UTC 2010
> x86_64 GNU/Linux
> Server version: Apache/2.2.11 (Ubuntu)
> Server built:   Nov 13 2009 22:06:57
> Server's Module Magic Number: 20051115:21
> Server loaded:  APR 1.2.12, APR-Util 1.2.12
> Compiled using: APR 1.2.12, APR-Util 1.2.12
> Architecture:   64-bit
> Server MPM:     Prefork
>  threaded:     no
>   forked:     yes (variable process count)
> Server compiled with....
> -D APACHE_MPM_DIR="server/mpm/prefork"
> -D APR_HAS_SENDFILE
> -D APR_HAS_MMAP
> -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
> -D APR_USE_SYSVSEM_SERIALIZE
> -D APR_USE_PTHREAD_SERIALIZE
> -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
> -D APR_HAS_OTHER_CHILD
> -D AP_HAVE_RELIABLE_PIPED_LOGS
> -D DYNAMIC_MODULE_LIMIT=128
> -D HTTPD_ROOT=""
> -D SUEXEC_BIN="/usr/lib/apache2/suexec"
> -D DEFAULT_PIDLOG="/var/run/apache2.pid"
> -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
> -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
> -D DEFAULT_ERRORLOG="logs/error_log"
> -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
> -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"
>
> This is the main configuration of apache2:
> <IfModule mpm_prefork_module>
>   StartServers          5
>   MinSpareServers       5
>   MaxSpareServers      9
>   MaxClients          80
>   MaxRequestsPerChild   400
>   MaxMemFree  200000
> </IfModule>
>
> KeepAliveTimeout 3
> MaxKeepAliveRequests 50
> KeepAlive On
> Timeout 200
>

Add more memory/reduce number of clients/disable KeepAlive.

30-50 MB per child sounds large, unless you are using PHP, in which
case it sounds about right.

You also seem to allow a very large number of children - MaxClients
80. If you are running out of memory, and can't add any more, don't
configure apache so that it can use 2.4 GB - 4 GB of RAM.

KeepAlive is good for clients, less good for pre-fork webservers
consuming lots of resources. Each client you KeepAlive adds one more
unusable child, another 30-50MB of memory used.

Cheers

Tom

---------------------------------------------------------------------
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


[users@httpd] memory problems, I lose control of the entire server

Posted by Alvise Nicoletti <li...@alvisenicoletti.com>.
Hi.
I searched help from several months ago with no success.
So I'll repeat again my problem hoping that this time someone will answer.

I often (3 times in a month) control of my virtual server, so I have to 
call the provider to soft-reset it.
The problem is that apache takes all the memory and the cpu usage of the 
server, and sometimes after that I have also kernel panic errors.

Even with the server working, I have the apache2 daemons big from 30 to 
50 megabytes each one (now I use 9).


In the logs I found stuff like this:
Feb 28 12:54:09 utopia kernel: [408986.594006] apache2 invoked 
oom-killer: gfp_mask=0x1201d2, order=0, oomkilladj=0
Feb 28 12:54:09 utopia kernel: [408986.594022] Pid: 6817, comm: apache2 
Not tainted 2.6.28-18-server #59-Ubuntu
Feb 28 12:54:09 utopia kernel: [408986.594026] Call Trace:
Feb 28 12:54:09 utopia kernel: [408986.594080]  [<ffffffff802b3825>] 
oom_kill_process+0x95/0x240
Feb 28 12:54:09 utopia kernel: [408986.594087]  [<ffffffff802b3fdf>] ? 
select_bad_process+0xef/0x130
Feb 28 12:54:09 utopia kernel: [408986.594091]  [<ffffffff802b40d4>] 
out_of_memory+0xb4/0x150
Feb 28 12:54:09 utopia kernel: [408986.594095]  [<ffffffff802b6c49>] 
__alloc_pages_internal+0x4a9/0x4f0
Feb 28 12:54:09 utopia kernel: [408986.594101]  [<ffffffff802b9a7a>] 
__do_page_cache_readahead+0xda/0x210
Feb 28 12:54:09 utopia kernel: [408986.594105]  [<ffffffff802b9c0e>] 
do_page_cache_readahead+0x5e/0x90
Feb 28 12:54:09 utopia kernel: [408986.594108]  [<ffffffff802b201a>] 
filemap_fault+0x34a/0x430
Feb 28 12:54:09 utopia kernel: [408986.594113]  [<ffffffff802c6010>] 
__do_fault+0x50/0x520
Feb 28 12:54:09 utopia kernel: [408986.594117]  [<ffffffff802c7199>] 
handle_mm_fault+0x1e9/0x470
Feb 28 12:54:09 utopia kernel: [408986.594134]  [<ffffffff802f3a1f>] ? 
path_walk+0xbf/0xd0
Feb 28 12:54:09 utopia kernel: [408986.594158]  [<ffffffff8022f669>] ? 
default_spin_lock_flags+0x9/0x10
Feb 28 12:54:09 utopia kernel: [408986.594177]  [<ffffffff8069e0d7>] 
do_page_fault+0x307/0x780
Feb 28 12:54:09 utopia kernel: [408986.594183]  [<ffffffff802eb9f3>] ? 
cp_new_stat+0xe3/0xf0
Feb 28 12:54:09 utopia kernel: [408986.594186]  [<ffffffff802ebee6>] ? 
sys_newstat+0x36/0x50
Feb 28 12:54:09 utopia kernel: [408986.594198]  [<ffffffff8069b6ba>] 
error_exit+0x0/0x70
Feb 28 12:54:09 utopia kernel: [408986.594202] Mem-Info:
Feb 28 12:54:09 utopia kernel: [408986.594205] DMA per-cpu:
Feb 28 12:54:09 utopia kernel: [408986.594207] CPU    0: hi:    0, 
btch:   1 usd:   0
Feb 28 12:54:09 utopia kernel: [408986.594210] CPU    1: hi:    0, 
btch:   1 usd:   0
Feb 28 12:54:09 utopia kernel: [408986.594212] DMA32 per-cpu:
Feb 28 12:54:09 utopia kernel: [408986.594214] CPU    0: hi:  186, 
btch:  31 usd: 183
Feb 28 12:54:09 utopia kernel: [408986.594216] CPU    1: hi:  186, 
btch:  31 usd: 172
Feb 28 12:54:09 utopia kernel: [408986.594226] Active_anon:363780 
active_file:19 inactive_anon:121250
Feb 28 12:54:09 utopia kernel: [408986.594228]  inactive_file:91 
unevictable:0 dirty:0 writeback:0 unstable:0
Feb 28 12:54:09 utopia kernel: [408986.594229]  free:3066 slab:4774 
mapped:1 pagetables:7473 bounce:0
Feb 28 12:54:09 utopia kernel: [408986.594234] DMA free:6644kB min:12kB 
low:12kB high:16kB active_anon:0kB inactive_anon:0kB acti$
Feb 28 12:54:09 utopia kernel: [408986.594237] lowmem_reserve[]: 0 2004 
2004 2004
Feb 28 12:54:09 utopia kernel: [408986.594244] DMA32 free:5620kB 
min:5720kB low:7148kB high:8580kB active_anon:1455120kB inactive$
Feb 28 12:54:09 utopia kernel: [408986.594247] lowmem_reserve[]: 0 0 0 0
Feb 28 12:54:09 utopia kernel: [408986.594259] DMA: 3*4kB 3*8kB 3*16kB 
3*32kB 3*64kB 1*128kB 2*256kB 1*512kB 1*1024kB 0*2048kB 1*$
Feb 28 12:54:09 utopia kernel: [408986.594272] DMA32: 155*4kB 1*8kB 
0*16kB 0*32kB 0*64kB 1*128kB 1*256kB 1*512kB 0*1024kB 0*2048k$
Feb 28 12:54:09 utopia kernel: [408986.594284] 828 total pagecache pages
Feb 28 12:54:09 utopia kernel: [408986.594286] 0 pages in swap cache
Feb 28 12:54:09 utopia kernel: [408986.594288] Swap cache stats: add 
4551, delete 4551, find 160864/160937
Feb 28 12:54:09 utopia kernel: [408986.594297] Free swap  = 0kB
Feb 28 12:54:09 utopia kernel: [408986.594299] Total swap = 0kB
Feb 28 12:54:09 utopia kernel: [408986.608274] 524272 pages RAM
Feb 28 12:54:09 utopia kernel: [408986.608283] 15596 pages reserved
Feb 28 12:54:09 utopia kernel: [408986.608284] 63040 pages shared
Feb 28 12:54:09 utopia kernel: [408986.608286] 500299 pages non-shared
Feb 28 12:54:09 utopia kernel: [408986.608292] Out of memory: kill 
process 6817 (apache2) score 63892 or a child
Feb 28 12:54:09 utopia kernel: [408986.609426] Killed process 6817 (apache2)
Feb 28 12:54:17 utopia kernel: [409094.110911] pickup invoked 
oom-killer: gfp_mask=0x1201d2, order=0, oomkilladj=0
Feb 28 12:54:17 utopia kernel: [409094.110925] Pid: 5668, comm: pickup 
Not tainted 2.6.28-18-server #59-Ubuntu
Feb 28 12:54:17 utopia kernel: [409094.110929] Call Trace:
(and so on)

This is my configuration:
Linux utopia 2.6.28-18-server #59-Ubuntu SMP Thu Jan 28 02:25:03 UTC 
2010 x86_64 GNU/Linux
Server version: Apache/2.2.11 (Ubuntu)
Server built:   Nov 13 2009 22:06:57
Server's Module Magic Number: 20051115:21
Server loaded:  APR 1.2.12, APR-Util 1.2.12
Compiled using: APR 1.2.12, APR-Util 1.2.12
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT=""
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"

This is the main configuration of apache2:
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      9
    MaxClients          80
    MaxRequestsPerChild   400
    MaxMemFree  200000
</IfModule>

KeepAliveTimeout 3
MaxKeepAliveRequests 50
KeepAlive On
Timeout 200

---------------------------------------------------------------------
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


[users@httpd] Re: Cacthing hosts

Posted by LuKreme <kr...@kreme.com>.
On 28-Feb-10 03:13, Nilesh Govindarajan wrote:
> On Sun, Feb 28, 2010 at 1:01 AM, LuKreme<kr...@kreme.com>  wrote:
>> On 27-Feb-2010, at 10:17, Nilesh Govindarajan wrote:
>>> What if I want all IPs ?
>>
>> What I posted will do what you want. Request to www.example.com will go to
>> the example.com dir, www.example.net will go to the example.net dir,
>> *everything*else* that reaches your server will go to the 400 error
>> VirtualHost.
>>
>> And I do mean *everything*

> You posted which will work for a single IP i.e. 12.34.56.789

No, you're not listening. EVERY REQUEST THAT MAKES IT TO APACHE and is 
NOT www.example.com or www.example.net will hit the first VirtualHost.

This is why I said *EVERYTHING*ELSE*

> But what if I have three or four IP addresses on the same Apache server ?

As long as apache is listening to thoes IPs it makes no difference.

> Your config will handle only that particular IP.

No, it won't. It would handle every single IP on the Internet if they 
all pointed at your apache install.


---------------------------------------------------------------------
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


Re: [users@httpd] Re: Cacthing hosts

Posted by Eric Covener <co...@gmail.com>.
On Sun, Feb 28, 2010 at 5:13 AM, Nilesh Govindarajan <li...@itech7.com> wrote:

> You posted which will work for a single IP i.e. 12.34.56.789
>
> But what if I have three or four IP addresses on the same Apache server ?
>
> Your config will handle only that particular IP.
>
> I think a solution is ServerAlias ?

Not necessary. When you create a set of name-based virtualhosts (1
NameVirtualHost X, N <virtualhost X>), the first one you list is the
default for that set.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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


RE: [users@httpd] Apache 2.2 optimization -> Three tips

Posted by Geoff Millikan <gm...@t1shopper.com>.
> +1.  Isn't that documented?  I'm surprised!

Suppose so, as a n00b though, I thought maybe cutting the default time of 15
in half would do it.  It didn't.  With many people on fast Internet
connections now, even 1 or 2 second KeepAliveTimeout's seem to work good.
 
> Interesting!  Do you have any insights into how this varies 
> with filesystem and operating system/hardware behaviour?  
> If this comes close to the difference made by .htaccess, 
> I'd be looking at what lies beneath.

Unfortunately the day we did this we also optimized a bunch of MySQL
queries.  That aside, and with the disclaimer that we're total newbies at
file system optimization, we saw was about a 40% decrease in CPU time and (I
have no idea why on this) about 20% more free RAM memory.  We're on ext3
filesystem but it would seem like any gain you'd see from noatime would be
impactful on any filesystem but I have no idea.  I can say that of all the
tuning we've done to the system, the noatime and the MinSpareServers
produced the most immediate, "I can see a difference with my naked eye" type
results.  YMMV.  The article below had convincing data which led us to try
it but screwing with our filesystem isn't something we took lightly:
http://www.philchen.com/2009/02/09/some-tuning-tips-for-apache-mod_cache-mod
_disk_cache

> Furthermore, what you describe appears to assume prefork MPM,
> which is unlikely to be the best solution where performance 
> is an issue.

Agreed, from what I've read worker MPM seems better but as you guys may
know, if you want tech support from Red Hat on RHEL5, you're stuck with
prefork.  Otherwise it's recompile time (yes, all the books say everything
should be recompiled) and if something goes haywire we're screwed with no
tech support (albeit the tech support from Red Hat hasn't been very helpful
anyway).

Re: [users@httpd] Apache 2.2 optimization -> Three tips

Posted by Nick Kew <ni...@webthing.com>.
On 22 Mar 2010, at 08:34, Geoff Millikan wrote:

> Here's three things I wish I had read about Apache optimization that are not
> commonly discussed (we found out by years of trial and error).

Thanks for sharing!

> 1. Set your KeepAliveTimeout to 3 seconds or less.

+1.  Isn't that documented?  I'm surprised!

> 2. Turn off atime "accesss time" by using noatime.

Interesting!  Do you have any insights into how this varies with filesystem
and operating system/hardware behaviour?  If this comes close to the
difference made by .htaccess, I'd be looking at what lies beneath.

> 3. Increase your StartServers to the number of maximum requests on your
> biggest page.

I'm with wrowe on this one: what you're getting is coincidence if anything.
Your clients should be using keepalive for objects on a page.
Furthermore, what you describe appears to assume prefork MPM,
which is unlikely to be the best solution where performance is an issue.

> Money and premature optimization is the root of all evil.

:-)

-- 
Nick Kew
---------------------------------------------------------------------
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


Re: [users@httpd] Apache 2.2 optimization -> Three tips

Posted by 夏蒸鑫 <xi...@limsoft.co.cc>.
thanks for your tips.

Best regards,
Sharl.Jimh.Tsin

---------------------------------------------------------------------
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


Re: [users@httpd] Apache 2.2 optimization -> Three tips

Posted by Tom Evans <te...@googlemail.com>.
On Mon, Mar 22, 2010 at 3:45 PM, Geoff Millikan <gm...@t1shopper.com> wrote:
>> Fair enough, but if your testing was of ~30 requests, and we
>> are believing that
>> the typical browser is making 6 simultaneous connections,
>> then it sounds like
>> the real magic was 6 * fudge factor of 5 ;-P
>
> LOL, yes, I totally agree and I kept thinking that no optimization guide has
> MinSpareServers and StartServers in the 20ies, 30ies or 40ies so I kept
> telling myself that there's no way that the "waiting" issues we saw could be
> solved by increasing the Servers.  However, we eliminated everything else:
> we're on 100Mbit Internet connection in 1 Wilshire, Los Angeles which is one
> of the more interconnected buildings in the USA, network optimized (all
> hardware Cisco GigE rated), server NIC cards all GigE rated and tuned, file
> system optimized (see noatime) and disk buffers optimized on RAID 10, extra
> RAM to spare, DNS resolution times tested, etc, etc, etc.  We were going
> crazy. We started looking into serving content with Lighttpd or Nginx to try
> and get around the issue but didn't want to configure/maintain more web
> servers so went back to the drawing board with Apache.
>
> Increasing MinSpareServers and StartServers beyond "normal" is what solved
> the issue for us.
>
> Although it doesn't make sense it seems 5 or 10 or more servers cannot
> *simultaneously* both read 35 files off the server and serve them.  Now if
> the Client is on dial-up, or mediocre DSL then the extra 500ms to 800ms of
> wait time probably wouldn't even be noticed as the last few images streaming
> in and the page finishes rendering.  But our office is on a 20 Mbps Verizon
> fiber link, and many of our customers are on fast pipes.  So we really do
> notice the difference between a web page that "snaps up to attention" and
> one that renders 90% with the last few pieces shuffling around.
>
> Best,
>
> http://www.t1shopper.com/
>
> -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> "The nine most terrifying words in the English language are: I'm from the
> government and I'm here to help." - Ronald Reagan, August 21, 1986
> -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>

Have you considered using a more resource effective MPM, like worker
or event? (disclaimer: I love the event MPM!)

If it is pure static hosting, then worker/event is a no-brainer. For
PHP/Python/etc you simply run the web app out of process and
communicate via WSGI or FastCGI (WSGI if you just do Python, FastCGI
if you prefer to be language agnostic).

Cheers

Tom

---------------------------------------------------------------------
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


RE: [users@httpd] Apache 2.2 optimization -> Three tips

Posted by Geoff Millikan <gm...@t1shopper.com>.
> Fair enough, but if your testing was of ~30 requests, and we 
> are believing that
> the typical browser is making 6 simultaneous connections, 
> then it sounds like
> the real magic was 6 * fudge factor of 5 ;-P

LOL, yes, I totally agree and I kept thinking that no optimization guide has
MinSpareServers and StartServers in the 20ies, 30ies or 40ies so I kept
telling myself that there's no way that the "waiting" issues we saw could be
solved by increasing the Servers.  However, we eliminated everything else:
we're on 100Mbit Internet connection in 1 Wilshire, Los Angeles which is one
of the more interconnected buildings in the USA, network optimized (all
hardware Cisco GigE rated), server NIC cards all GigE rated and tuned, file
system optimized (see noatime) and disk buffers optimized on RAID 10, extra
RAM to spare, DNS resolution times tested, etc, etc, etc.  We were going
crazy. We started looking into serving content with Lighttpd or Nginx to try
and get around the issue but didn't want to configure/maintain more web
servers so went back to the drawing board with Apache.

Increasing MinSpareServers and StartServers beyond "normal" is what solved
the issue for us.  

Although it doesn't make sense it seems 5 or 10 or more servers cannot
*simultaneously* both read 35 files off the server and serve them.  Now if
the Client is on dial-up, or mediocre DSL then the extra 500ms to 800ms of
wait time probably wouldn't even be noticed as the last few images streaming
in and the page finishes rendering.  But our office is on a 20 Mbps Verizon
fiber link, and many of our customers are on fast pipes.  So we really do
notice the difference between a web page that "snaps up to attention" and
one that renders 90% with the last few pieces shuffling around.

Best,

http://www.t1shopper.com/

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
"The nine most terrifying words in the English language are: I'm from the
government and I'm here to help." - Ronald Reagan, August 21, 1986
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Re: [users@httpd] Apache 2.2 optimization -> Three tips

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 3/22/2010 5:08 AM, Geoff Millikan wrote:
>> if your server averages 300 simulatious connections, you need
>> to start with 300 servers, and you never want it to drop
>> below that number.
> 
> Your experience might show otherwise however based on our experience - if we
> averaged 300 new customers/min at once (not 300 requests/sec) a
> MinSpareServers of 300 wouldn't be enough.

A connection is not a customer, as we discuss below.  I'm using the technical,
networking term connection, and this is what you can observe in mod_status
over a period of time to calculate an average (and min/max).

>> Yes, a browser can make multiple connections, but this is 
>> typically only two
>> parallel pipelines, perhaps even four.  
> 
> The "average" browser now makes 6 parallel connections per hostname per:
> http://www.browserscope.org/

Interesting research, thanks!

>> But 30 workers are not handling the 30 requests comprising
>> one user connecting to your site!!!  You just happened
>> to hit a magic correlation in your testing :)
> 
> I agree, the way I understand the prefork model to work, the 30 processes
> aren't each serving one of the 30+ requests this Customer's browser made (is
> keepalive tracked across processes?).  However, the way the testing worked
> out for us, it seems that way.  We did a lot of testing to come up with our
> numbers and just "ball parking" it, the number of servers seemed to work out
> best when matched to the number of requests per page.  

Fair enough, but if your testing was of ~30 requests, and we are believing that
the typical browser is making 6 simultaneous connections, then it sounds like
the real magic was 6 * fudge factor of 5 ;-P


---------------------------------------------------------------------
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


RE: [users@httpd] Apache 2.2 optimization -> Three tips

Posted by Geoff Millikan <gm...@t1shopper.com>.
> if your server averages 300 simulatious connections, you need
> to start with 300 servers, and you never want it to drop
> below that number.

Your experience might show otherwise however based on our experience - if we
averaged 300 new customers/min at once (not 300 requests/sec) a
MinSpareServers of 300 wouldn't be enough.

> Yes, a browser can make multiple connections, but this is 
> typically only two
> parallel pipelines, perhaps even four.  

The "average" browser now makes 6 parallel connections per hostname per:
http://www.browserscope.org/

> But 30 workers are not handling the 30 requests comprising
> one user connecting to your site!!!  You just happened
> to hit a magic correlation in your testing :)

I agree, the way I understand the prefork model to work, the 30 processes
aren't each serving one of the 30+ requests this Customer's browser made (is
keepalive tracked across processes?).  However, the way the testing worked
out for us, it seems that way.  We did a lot of testing to come up with our
numbers and just "ball parking" it, the number of servers seemed to work out
best when matched to the number of requests per page.  

Don't take my word for it, use Firebug and test it - if you're seeing big
"waiting" bar times and you know you have the bandwidth on both ends (ask
you web host how much burst or max bandwidth you get), then up the
MinSpareServers and see what happens (comment out the MaxSpareServers).  For
the record, our site averages ~3 requests per second 24-hours a day and
averages about 35 (ugh, I know) requests per page.  Really should be using
CSS sprites to cut down on the number of requests but instead I'm typing
this and pretending I shouldn't be going to bed.  ;-)

Best,

http://www.t1shopper.com/

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
"The nine most terrifying words in the English language are: I'm from the
government and I'm here to help." - Ronald Reagan, August 21, 1986
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Re: [users@httpd] Apache 2.2 optimization -> Three tips

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 3/22/2010 3:34 AM, Geoff Millikan wrote:
> Here's three things I wish I had read about Apache optimization that are not
> commonly discussed (we found out by years of trial and error).

Agreed, agreed, and *huh*?

> 3. Increase your StartServers to the number of maximum requests on your
> biggest page.  For example, if your busiest page requires 30 hits/requests
> to load all the images, css, javascript, etc then 

It needs to be generously sized, but not users * maxrequests.  Just starting
your average server load is correct, e.g. if your server averages 300 simulatious
connections, you need to start with 300 servers, and you never want it to drop
below that number.

Yes, a browser can make multiple connections, but this is typically only two
parallel pipelines, perhaps even four.  But 30 workers are not handling the
30 requests comprising one user connecting to your site!!!  You just happened
to hit a magic correlation in your testing :)

---------------------------------------------------------------------
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


[users@httpd] Apache 2.2 optimization -> Three tips

Posted by Geoff Millikan <gm...@t1shopper.com>.
Here's three things I wish I had read about Apache optimization that are not
commonly discussed (we found out by years of trial and error).  These three
settings are worth more than all the other optimization we've done (e.g.
SendBufferSize, AcceptFilter http data, EnableMMAP On, EnableSendfile On,
eliminating all .htaccess files, etc.)

1. Set your KeepAliveTimeout to 3 seconds or less.

2. Turn off atime "accesss time" by using noatime.  Do it in real time with
*something like* the command line below.  This will make it so you only have
to read the file off the disk instead of doing both a read (to get the data)
then a write to update the access time.

shell> mount -o noatime,remount,rw / 

To make the noatime setting last between reboots edit your fstab and modify
this line:
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
To read *something like* to like this:
/dev/VolGroup00/LogVol00 /                       ext3    defaults,noatime
1 1

3. Increase your StartServers to the number of maximum requests on your
biggest page.  For example, if your busiest page requires 30 hits/requests
to load all the images, css, javascript, etc then if you have the RAM to
support it, set your StartServers to 30 and your MinSpareServers to 30.  To
know if you have the RAM to support it, run the command "top" and look for
the httpd process under the column "RES."  That's the amount of physical RAM
the Apache process is taking up.  On our server, each process take up about
12 megs of RAM.  So having 30 Apache process running will takes up 360 megs
of RAM.  Now use Firefox Firebug.  Look at the time each item is in
"waiting."  Before you increased  StartServers you might see the first 10 or
20 items have a "waiting" time of 20 to 30 ms then the last 10 items have a
"waiting" time of 300 or 500ms or more.  When you have enough processes
going, all the "waiting" times will be about the same.  Don't raise your
StartServers above the amount of RAM available otherwise you'll swap which
I've read is very slow (you can tell by looking at the "top" output under
the row called "swap").

Money and premature optimization is the root of all evil.

Best,

http://www.t1shopper.com/


-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
"The nine most terrifying words in the English language are: I'm from the
government and I'm here to help." - Ronald Reagan, August 21, 1986
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Re: [users@httpd] Re: Cacthing hosts

Posted by Nilesh Govindarajan <li...@itech7.com>.
On Sun, Feb 28, 2010 at 1:01 AM, LuKreme <kr...@kreme.com> wrote:

> On 27-Feb-2010, at 10:17, Nilesh Govindarajan wrote:
> >
> > What if I want all IPs ?
>
> Your not understanding the function of the first VirtualHost. It is special
> as it is the default for anything that doesn't match another VirtualHost.
>
> What I posted will do what you want. Request to www.example.com will go to
> the example.com dir, www.example.net will go to the example.net dir,
> *everything*else* that reaches your server will go to the 400 error
> VirtualHost.
>
> And I do mean *everything*
>
> --
> 'I think, if you want thousands, you've got to fight for one.' --Small Gods
>
>
> ---------------------------------------------------------------------
> 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
>
>
You posted which will work for a single IP i.e. 12.34.56.789

But what if I have three or four IP addresses on the same Apache server ?

Your config will handle only that particular IP.

I think a solution is ServerAlias ?

-- 
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com

[users@httpd] Re: Cacthing hosts

Posted by LuKreme <kr...@kreme.com>.
On 27-Feb-2010, at 10:17, Nilesh Govindarajan wrote:
> 
> What if I want all IPs ?

Your not understanding the function of the first VirtualHost. It is special as it is the default for anything that doesn't match another VirtualHost.

What I posted will do what you want. Request to www.example.com will go to the example.com dir, www.example.net will go to the example.net dir, *everything*else* that reaches your server will go to the 400 error VirtualHost.

And I do mean *everything*

-- 
'I think, if you want thousands, you've got to fight for one.' --Small Gods


---------------------------------------------------------------------
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


Re: [users@httpd] Re: Cacthing hosts

Posted by Nilesh Govindarajan <li...@itech7.com>.
On Sat, Feb 27, 2010 at 9:31 PM, LuKreme <kr...@kreme.com> wrote:

> On 27-Feb-2010, at 04:20, Nilesh Govindarajan wrote:
> >
> > This configuration has to be placed after all good vhosts; Otherwise all
> > hosts give Error 400. Why ?
>
> Because all hosts match.
>
> This is not the best way to do it, wildcards are discouraged.
>
> As Frank said:
>
> On 26-Feb-2010, at 10:22, Frank Gingras wrote:
> > If you want to define a dummy catch-all vhost, you should place it first,
> and set the ServerName to another value like your IP or a dummy name.
>
> First Virtual Host:
> <VirtualHost *>
>  Servername 12.34.56.789
>  RedirectMatch 400 ^/.*
> </virtualhost>
>
> then put the real virtual hosts you want to define down here
>
> <virtualhost *>
>  Servername www.example.com
>  DocumentRoot /path/to/example.com
> </virtualhost>
>
> <virtualhost *>
>  Servername www.example.net
>  DocumentRoot /path/to/example.net
> </virtualhost>
>
>
> The servername in your dummy can be something else. dummy.example.com, for
> example, but making it the IP address is probably a good choice.
>
> --
> "You're just impressed by any pretty girl who can walk and talk."
> "She doesn't have to talk."
>
>
> ---------------------------------------------------------------------
> 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
>
>
What if I want all IPs ?

-- 
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com

[users@httpd] Re: Cacthing hosts

Posted by LuKreme <kr...@kreme.com>.
On 27-Feb-2010, at 04:20, Nilesh Govindarajan wrote:
> 
> This configuration has to be placed after all good vhosts; Otherwise all
> hosts give Error 400. Why ?

Because all hosts match.

This is not the best way to do it, wildcards are discouraged.

As Frank said:

On 26-Feb-2010, at 10:22, Frank Gingras wrote:
> If you want to define a dummy catch-all vhost, you should place it first, and set the ServerName to another value like your IP or a dummy name.

First Virtual Host:
<VirtualHost *>
  Servername 12.34.56.789
  RedirectMatch 400 ^/.*
</virtualhost>

then put the real virtual hosts you want to define down here

<virtualhost *>
  Servername www.example.com
  DocumentRoot /path/to/example.com
</virtualhost>

<virtualhost *>
  Servername www.example.net
  DocumentRoot /path/to/example.net
</virtualhost>


The servername in your dummy can be something else. dummy.example.com, for example, but making it the IP address is probably a good choice.

-- 
"You're just impressed by any pretty girl who can walk and talk."
"She doesn't have to talk."


---------------------------------------------------------------------
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


Re: [users@httpd] Cacthing hosts

Posted by Nilesh Govindarajan <li...@itech7.com>.
On Fri, Feb 26, 2010 at 10:52 PM, Frank Gingras
<fr...@gmail.com>wrote:

>
>
> On 02/26/2010 12:12 PM, Tom Evans wrote:
>
>> On Fri, Feb 26, 2010 at 4:57 PM, Nilesh Govindarajan<li...@itech7.com>
>>  wrote:
>>
>>> Hi,
>>>
>>> I have two domains, example.net and example.com
>>>
>>> *.example.net&  *.example.com point to the server's IP (Wildcard CNAME).
>>>
>>> Now only some subdomains like www, img, etc. are defined on both domains.
>>>
>>> I want to catch all other subdomains not configured and raise a 404
>>> error.
>>>
>>> How to ?
>>>
>>> --
>>> Nilesh Govindarajan
>>> Site&  Server Administrator
>>> www.itech7.com
>>>
>>>
>>>
>> I don't know about 404, but you can have them raise a 403 easily enough:
>>
>> <VirtualHost *:80>
>>   ServerName www.example.com
>> </VirtualHost>
>>
>> <VirtualHost *:80>
>>   ServerName *.example.com
>>   RewriteEngine On
>>   RewriteRule ^ - [F]
>> </VirtualHost>
>>
>> Cheers
>>
>> Tom
>>
>> ---------------------------------------------------------------------
>> 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
>>
>>
> Tom,
>
> Note that using a wildcard with ServerName is not recommended. If you want
> to define a dummy catch-all vhost, you should place it first, and set the
> ServerName to another value like your IP or a dummy name.
>
> Frank.
>
>
> ---------------------------------------------------------------------
> 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
>
>
Though I've got it, I have a doubt. I'm using this config -

<VirtualHost *:80>
ServerAlias *.example.com *.example.net
RedirectMatch 400 ^/(.*)$
</VirtualHost>

This configuration has to be placed after all good vhosts; Otherwise all
hosts give Error 400. Why ?

-- 
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com

Re: [users@httpd] Cacthing hosts

Posted by Frank Gingras <fr...@gmail.com>.

On 02/26/2010 12:12 PM, Tom Evans wrote:
> On Fri, Feb 26, 2010 at 4:57 PM, Nilesh Govindarajan<li...@itech7.com>  wrote:
>> Hi,
>>
>> I have two domains, example.net and example.com
>>
>> *.example.net&  *.example.com point to the server's IP (Wildcard CNAME).
>>
>> Now only some subdomains like www, img, etc. are defined on both domains.
>>
>> I want to catch all other subdomains not configured and raise a 404 error.
>>
>> How to ?
>>
>> --
>> Nilesh Govindarajan
>> Site&  Server Administrator
>> www.itech7.com
>>
>>
>
> I don't know about 404, but you can have them raise a 403 easily enough:
>
> <VirtualHost *:80>
>    ServerName www.example.com
> </VirtualHost>
>
> <VirtualHost *:80>
>    ServerName *.example.com
>    RewriteEngine On
>    RewriteRule ^ - [F]
> </VirtualHost>
>
> Cheers
>
> Tom
>
> ---------------------------------------------------------------------
> 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
>

Tom,

Note that using a wildcard with ServerName is not recommended. If you 
want to define a dummy catch-all vhost, you should place it first, and 
set the ServerName to another value like your IP or a dummy name.

Frank.

---------------------------------------------------------------------
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


Re: [users@httpd] Cacthing hosts

Posted by Tom Evans <te...@googlemail.com>.
On Fri, Feb 26, 2010 at 4:57 PM, Nilesh Govindarajan <li...@itech7.com> wrote:
> Hi,
>
> I have two domains, example.net and example.com
>
> *.example.net & *.example.com point to the server's IP (Wildcard CNAME).
>
> Now only some subdomains like www, img, etc. are defined on both domains.
>
> I want to catch all other subdomains not configured and raise a 404 error.
>
> How to ?
>
> --
> Nilesh Govindarajan
> Site & Server Administrator
> www.itech7.com
>
>

I don't know about 404, but you can have them raise a 403 easily enough:

<VirtualHost *:80>
  ServerName www.example.com
</VirtualHost>

<VirtualHost *:80>
  ServerName *.example.com
  RewriteEngine On
  RewriteRule ^ - [F]
</VirtualHost>

Cheers

Tom

---------------------------------------------------------------------
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