You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Norman Khine <no...@khine.net> on 2007/03/05 11:22:26 UTC

[users@httpd] Awstats and re-write rule for Zope

Hello,
I have a Zope instance running on port 8080 with the following
httpd.conf vhost directive

<VirtualHost *:80>
  ServerName domain.com
  ServerAlias www.domain.com
  RewriteEngine On

  #Deny hosts map
  #
  RewriteMap    hosts-deny      txt:/home/xxx/apache/hosts.deny
  RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
  RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
  RewriteCond   ${hosts-deny:%{HTTP:true-client-ip}|NOT-FOUND} !=NOT-FOUND
  RewriteRule   ^/.*  -  [F]

  #Awstats rewrite
  #
  RewriteRule   /awstats-icon(.*)
/usr/share/webapps/awstats/6.5-r1/hostroot/icon/$1 [last]
  RewriteRule /stats(.*)
/usr/share/webapps/awstats/6.5-r1/hostroot/cgi-bin/awstats.pl$1 [last]

  #ZOPE rewrite
  #
  RewriteRule ^/(.*)
http://domain.com:8080/VirtualHostBase/http/domain.com:80/users/user/VirtualHostRoot/$1
[L,P]

  #Logs
  ErrorLog /var/log/apache2/domain.com_error.log
  CustomLog /var/log/apache2/domain.com_access.log combined
  RewriteLog /var/log/apache2/domain.com_rewrite_log
</VirtualHost>


Everything works fine, but when I go to http://domain.com/stats Apache
still points to the ZOPE server and does not take into account the
Awstats rule!

Awstats works, as when I comment out the ZOPE rewrite rule and then
point my browser to http://domain.com/stats I get the stats page.

Is there a way in which I can make this work for the two servers?

Cheers

Norman






---------------------------------------------------------------------
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] Awstats and re-write rule for Zope

Posted by Norman Khine <no...@khine.net>.

Vincent Bray wrote:
> On 08/03/07, Norman Khine <no...@khine.net> wrote:
>> <VirtualHost *:80>
>>   ServerName domain.com
>>   ServerAlias www.domain.com
>>   RewriteEngine On
>>   #DenyHosts Rules
>>   RewriteMap    hosts-deny      txt:/home/user/apache/hosts.deny
>>   RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
>>   RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
>>   RewriteCond   ${hosts-deny:%{HTTP:true-client-ip}|NOT-FOUND}
>> !=NOT-FOUND
>>   RewriteRule   ^/.*  -  [F]
>>   #AWStats Rules
>>   RewriteRule ^/awstats/(.*) /awstats/$1 [L,PT]
>>   RewriteRule ^/awstatsclasses/(.*) /awstatsclasses/$1 [L,PT]
>>   RewriteRule ^/awstatscss/(.*) /awstatscss/$1 [L,PT]
>>   RewriteRule ^/awstatsicons/(.*) /awstatsicons/$1 [L,PT]
>>   #Zope Rules
>>   RewriteRule ^/(.*)
>> http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/$1
>>
>> [L,P]
>>   Alias /awstatsclasses "/usr/share/webapps/awstats/6.5-r1/htdocs/"
>>   Alias /awstatscss "/usr/share/webapps/awstats/6.5-r1/htdocs/css/"
>>   Alias /awstatsicons "/usr/share/webapps/awstats/6.5-r1/htdocs/icon/"
>>   Alias /icon "/usr/share/webapps/awstats/6.5-r1/htdocs/icon/"
>>   ScriptAlias /awstats/
>> "/usr/share/webapps/awstats/6.5-r1/hostroot/cgi-bin/"
>>   #Logs
>>   ErrorLog /var/log/apache2/domain_error.log
>>   CustomLog /var/log/apache2/domain_access.log combined
>>   RewriteLog /var/log/apache2/domain_rewrite_log
>>   RewriteLogLevel 9
>> </VirtualHost>
>>
>>
>> The RewriteLog does not give me any information as the site returned
>> when I go to http://domain.com/awstats is the one from the Zope server
>> and then I get a Zope Error that the page is not found.
>>
>> If I remove the Rule for zope, and then go to http://domain.com/awstats
>> it works fine.
> 
> Could you post a rewrite log of a request for /awstats? Your last post
> didn't include that and if as you say requesting /awstats proxies the
> request to zope, then your rewrite rules must be running, in one form
> or other.
> 
> Also, did you try my initial suggestion of putting a negative
> condition for /awstats prior to the proxy rule?
> 
> # No anchor before awstats
> RewriteCond %{REQUEST_URI} !awstats
> RewriteRule ^/(.*)
> http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/$1
> 
> [L,P]
> 

Nice one Vincent, many thanks the RewriteCond %{REQUEST_URI} !awstats
did the trick.

Thank you all.

Regards

Norman


---------------------------------------------------------------------
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] Awstats and re-write rule for Zope

Posted by Vincent Bray <no...@gmail.com>.
On 08/03/07, Norman Khine <no...@khine.net> wrote:
> <VirtualHost *:80>
>   ServerName domain.com
>   ServerAlias www.domain.com
>   RewriteEngine On
>   #DenyHosts Rules
>   RewriteMap    hosts-deny      txt:/home/user/apache/hosts.deny
>   RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
>   RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
>   RewriteCond   ${hosts-deny:%{HTTP:true-client-ip}|NOT-FOUND} !=NOT-FOUND
>   RewriteRule   ^/.*  -  [F]
>   #AWStats Rules
>   RewriteRule ^/awstats/(.*) /awstats/$1 [L,PT]
>   RewriteRule ^/awstatsclasses/(.*) /awstatsclasses/$1 [L,PT]
>   RewriteRule ^/awstatscss/(.*) /awstatscss/$1 [L,PT]
>   RewriteRule ^/awstatsicons/(.*) /awstatsicons/$1 [L,PT]
>   #Zope Rules
>   RewriteRule ^/(.*)
> http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/$1
> [L,P]
>   Alias /awstatsclasses "/usr/share/webapps/awstats/6.5-r1/htdocs/"
>   Alias /awstatscss "/usr/share/webapps/awstats/6.5-r1/htdocs/css/"
>   Alias /awstatsicons "/usr/share/webapps/awstats/6.5-r1/htdocs/icon/"
>   Alias /icon "/usr/share/webapps/awstats/6.5-r1/htdocs/icon/"
>   ScriptAlias /awstats/
> "/usr/share/webapps/awstats/6.5-r1/hostroot/cgi-bin/"
>   #Logs
>   ErrorLog /var/log/apache2/domain_error.log
>   CustomLog /var/log/apache2/domain_access.log combined
>   RewriteLog /var/log/apache2/domain_rewrite_log
>   RewriteLogLevel 9
> </VirtualHost>
>
>
> The RewriteLog does not give me any information as the site returned
> when I go to http://domain.com/awstats is the one from the Zope server
> and then I get a Zope Error that the page is not found.
>
> If I remove the Rule for zope, and then go to http://domain.com/awstats
> it works fine.

Could you post a rewrite log of a request for /awstats? Your last post
didn't include that and if as you say requesting /awstats proxies the
request to zope, then your rewrite rules must be running, in one form
or other.

Also, did you try my initial suggestion of putting a negative
condition for /awstats prior to the proxy rule?

# No anchor before awstats
RewriteCond %{REQUEST_URI} !awstats
RewriteRule ^/(.*)
http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/$1
[L,P]

-- 
noodl

---------------------------------------------------------------------
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] Awstats and re-write rule for Zope

Posted by Norman Khine <no...@khine.net>.
Thank you all of your help, but I am still having problems in setting
this up.

Here is the vhosts entry in my /etc/apache2/vhosts.d/domain.conf file

<VirtualHost *:80>
  ServerName domain.com
  ServerAlias www.domain.com
  RewriteEngine On
  #DenyHosts Rules
  RewriteMap    hosts-deny      txt:/home/user/apache/hosts.deny
  RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
  RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND [OR]
  RewriteCond   ${hosts-deny:%{HTTP:true-client-ip}|NOT-FOUND} !=NOT-FOUND
  RewriteRule   ^/.*  -  [F]
  #AWStats Rules
  RewriteRule ^/awstats/(.*) /awstats/$1 [L,PT]
  RewriteRule ^/awstatsclasses/(.*) /awstatsclasses/$1 [L,PT]
  RewriteRule ^/awstatscss/(.*) /awstatscss/$1 [L,PT]
  RewriteRule ^/awstatsicons/(.*) /awstatsicons/$1 [L,PT]
  #Zope Rules
  RewriteRule ^/(.*)
http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/$1
[L,P]
  Alias /awstatsclasses "/usr/share/webapps/awstats/6.5-r1/htdocs/"
  Alias /awstatscss "/usr/share/webapps/awstats/6.5-r1/htdocs/css/"
  Alias /awstatsicons "/usr/share/webapps/awstats/6.5-r1/htdocs/icon/"
  Alias /icon "/usr/share/webapps/awstats/6.5-r1/htdocs/icon/"
  ScriptAlias /awstats/
"/usr/share/webapps/awstats/6.5-r1/hostroot/cgi-bin/"
  #Logs
  ErrorLog /var/log/apache2/domain_error.log
  CustomLog /var/log/apache2/domain_access.log combined
  RewriteLog /var/log/apache2/domain_rewrite_log
  RewriteLogLevel 9
</VirtualHost>


The RewriteLog does not give me any information as the site returned
when I go to http://domain.com/awstats is the one from the Zope server
and then I get a Zope Error that the page is not found.

If I remove the Rule for zope, and then go to http://domain.com/awstats
it works fine.

Here is part of the RewriteLog

74.6.74.199 - - [07/Mar/2007:19:42:42 +0100]
[domain.com/sid#82b9c88][rid#84fa898/initial] (2) rewrite
/catalogue/c13586/c13840/c13956/c13965 ->
http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/catalogue/c13586/c13840/c13956/c13965
74.6.74.199 - - [07/Mar/2007:19:42:42 +0100]
[domain.com/sid#82b9c88][rid#84fa898/initial] (2) forcing
proxy-throughput with
http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/catalogue/c13586/c13840/c13956/c13965
74.6.74.199 - - [07/Mar/2007:19:42:42 +0100]
[domain.com/sid#82b9c88][rid#84fa898/initial] (1) go-ahead with proxy
request
proxy:http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/catalogue/c13586/c13840/c13956/c13965
[OK]
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (2) init rewrite engine
with requested uri /information/terms_conditions
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (3) applying pattern
'^/.*' to uri '/information/terms_conditions'
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (6) cache lookup FAILED,
forcing new map lookup
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (5) map lookup FAILED:
map=hosts-deny[txt] key=74.6.69.116
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (4) RewriteCond:
input='NOT-FOUND' pattern='!=NOT-FOUND' => not-matched
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (5) cache lookup OK:
map=hosts-deny[txt] key=74.6.69.116 -> val=
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (4) RewriteCond:
input='NOT-FOUND' pattern='!=NOT-FOUND' => not-matched
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (5) cache lookup OK:
map=hosts-deny[txt] key= -> val=
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (4) RewriteCond:
input='NOT-FOUND' pattern='!=NOT-FOUND' => not-matched
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (3) applying pattern
'^/awstats/(.*)' to uri '/information/terms_conditions'
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (3) applying pattern
'^/awstatsclasses/(.*)' to uri '/information/terms_conditions'
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (3) applying pattern
'^/awstatscss/(.*)' to uri '/information/terms_conditions'
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (3) applying pattern
'^/awstatsicons/(.*)' to uri '/information/terms_conditions'
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (3) applying pattern
'^/(.*)' to uri '/information/terms_conditions'
74.6.69.116 - - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (2) rewrite
/information/terms_conditions ->
http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/information/terms_conditions74.6.69.116
- - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (2) forcing
proxy-throughput with
http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/information/terms_conditions74.6.69.116
- - [07/Mar/2007:19:44:27 +0100]
[domain.com/sid#82b9c88][rid#85158f8/initial] (1) go-ahead with proxy
request
proxy:http://domain.com:4080/VirtualHostBase/http/domain.com:80/shops/shop1/VirtualHostRoot/information/terms_conditions
[OK]

Any insight into this, or pointers would be greatly appreciated.

Many thanks

Norman



Gaël Lams wrote:
> Hi
> 
> I personnaly use the following similare rewrite rules on a few zope
> instances and it works perfectly:
> 
>    RewriteEngine on
>    RewriteRule ^/awstats/(.*) /awstats/$1 [L,PT]
>    RewriteRule ^/awstatsclasses/(.*) /awstatsclasses/$1 [L,PT]
>    RewriteRule ^/awstatscss/(.*) /awstatscss/$1 [L,PT]
>    RewriteRule ^/awstatsicons/(.*) /awstatsicons/$1 [L,PT]
>    RewriteRule ^/(.*)
> http://localhost:8080/VirtualHostBase/http/%{HTTP_HOST}:80/folder_name/VirtualHostRoot/$1
> 
> [L,P]
> 
> plus the following lines:
> 
>    #
>    # Directives to add to your Apache conf file to allow use of
> AWStats as a CGI.
>    # Note that path "/usr/local/awstats/" must reflect your AWStats
> Installation path.
>    Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
>    Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
>    Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
>    Alias /icon "/usr/local/awstats/wwwroot/icon/"
>    ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
> 
> Kind regards,
> 
> Gaël
> 

-- 
Norman Khine
7 rue Ponscarme, Paris, 75013, France
tel +33 870 628 934 fax +33 142 724 4437
email: norman@khine.net

http://www.abakuc.com http://www.uktravellist.info
http://www.destinationsguide.info



---------------------------------------------------------------------
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] Awstats and re-write rule for Zope

Posted by Gaël Lams <la...@gmail.com>.
Hi

I personnaly use the following similare rewrite rules on a few zope
instances and it works perfectly:

    RewriteEngine on
    RewriteRule ^/awstats/(.*) /awstats/$1 [L,PT]
    RewriteRule ^/awstatsclasses/(.*) /awstatsclasses/$1 [L,PT]
    RewriteRule ^/awstatscss/(.*) /awstatscss/$1 [L,PT]
    RewriteRule ^/awstatsicons/(.*) /awstatsicons/$1 [L,PT]
    RewriteRule ^/(.*)
http://localhost:8080/VirtualHostBase/http/%{HTTP_HOST}:80/folder_name/VirtualHostRoot/$1
[L,P]

plus the following lines:

    #
    # Directives to add to your Apache conf file to allow use of
AWStats as a CGI.
    # Note that path "/usr/local/awstats/" must reflect your AWStats
Installation path.
    Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
    Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
    Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
    Alias /icon "/usr/local/awstats/wwwroot/icon/"
    ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"

Kind regards,

Gaël

Re: [users@httpd] Awstats and re-write rule for Zope

Posted by Vincent Bray <no...@gmail.com>.
On 05/03/07, Norman Khine <no...@khine.net> wrote:
> would the issue be something to do with the [last]

Perhaps. It'd help to see a rewrite log.

RewriteLog /tmp/rewrite.log
RewriteLogLevel 9

Remember to turn that off again, rewrite logs get big fast.
-- 
noodl

---------------------------------------------------------------------
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] Awstats and re-write rule for Zope

Posted by Norman Khine <no...@khine.net>.
would the issue be something to do with the [last]

Vincent Bray wrote:
> On 05/03/07, Norman Khine <no...@khine.net> wrote:
>>   #Awstats rewrite
>>   #
>>   RewriteRule   /awstats-icon(.*)
>> /usr/share/webapps/awstats/6.5-r1/hostroot/icon/$1 [last]
>>   RewriteRule /stats(.*)
>> /usr/share/webapps/awstats/6.5-r1/hostroot/cgi-bin/awstats.pl$1 [last]
>>
>>   #ZOPE rewrite
>>   #
>>   RewriteRule ^/(.*)
>> http://domain.com:8080/VirtualHostBase/http/domain.com:80/users/user/VirtualHostRoot/$1
>>
>> [L,P]
> 
> I can't think of any reason why the zope rewrite would trump the other
> one but anyway try making the skipping of /stats explicit. Add this
> directly before the rewrite to zope.
> 
> RewriteCond %{REQUEST_URI} !^/stats
> 

-- 
Norman Khine
7 rue Ponscarme, Paris, 75013, France
tel +33 870 628 934 fax +33 142 724 4437
email: norman@khine.net

http://www.abakuc.com http://www.uktravellist.info
http://www.destinationsguide.info



---------------------------------------------------------------------
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] Awstats and re-write rule for Zope

Posted by Vincent Bray <no...@gmail.com>.
On 05/03/07, Norman Khine <no...@khine.net> wrote:
>   #Awstats rewrite
>   #
>   RewriteRule   /awstats-icon(.*)
> /usr/share/webapps/awstats/6.5-r1/hostroot/icon/$1 [last]
>   RewriteRule /stats(.*)
> /usr/share/webapps/awstats/6.5-r1/hostroot/cgi-bin/awstats.pl$1 [last]
>
>   #ZOPE rewrite
>   #
>   RewriteRule ^/(.*)
> http://domain.com:8080/VirtualHostBase/http/domain.com:80/users/user/VirtualHostRoot/$1
> [L,P]

I can't think of any reason why the zope rewrite would trump the other
one but anyway try making the skipping of /stats explicit. Add this
directly before the rewrite to zope.

RewriteCond %{REQUEST_URI} !^/stats

-- 
noodl

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