Hi all, I've seen similar things discussed on the list, but not quite this question. I have setup the virtualhostmonster in my root folder. In my apache config, I have the following: <VirtualHost *> RewriteEngine On RewriteCond %{HTTP_HOST} ^.*$ RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/%{HTTP_HOST}:80/$1 [L,P] <IfModule mod_proxy.c> ProxyRequests On ProxyVia On </IfModule> </Virtualhost> The rewriterule has wrapped to two lines in this e-mail, but in my config it is on one. I have got an A record, zaphod-content.mydomain.com pointed at the IP Address that the Apache httpd server is listening on. In Zope, I have added a folder named zaphod-content.mydomain.com off of root. This has an index_html document in it. When I connect to http://zaphod-content.mydomain.com I get the normal localhost:8080/ page. If I go to http://zaphod-content.mydomain.com/zaphod-content.mydomain.com I get what I expect to. zaphod-content is not the primary name of this machine. The primary name is zaphod. Going to this also gives me the content I would expect to see at localhost:8080/ Any ideas why the contents of zaphod-content.mydomain.com are not being served as / when I request it as zaphod-content.mydomain.com ? TIA, -- Wayne Pascoe <wayne.pascoe@ehsbrann.com> Give me enough medals, and I'll win any war. - Napolean
Wayne, some remarks. Wayne Pascoe wrote:
Hi all,
I've seen similar things discussed on the list, but not quite this question.
I have setup the virtualhostmonster in my root folder. In my apache config, I have the following:
<VirtualHost *> RewriteEngine On RewriteCond %{HTTP_HOST} ^.*$ RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/%{HTTP_HOST}:80/$1 [L,P]
This won't work when a client includes the port in the host header, like Host: zaphod-content.mydomain.com:80. Some clients do that, wget for instance, and you'll get an extra ":80" in your request to zope.
<IfModule mod_proxy.c> ProxyRequests On
Are you sure you want that? You now have open your server as a proxy for the whole world, if no other access rules are installed. You don't need that for what you describe here, see http://httpd.apache.org/docs/mod/mod_proxy.html#proxyrequests
ProxyVia On </IfModule> </Virtualhost>
The rewriterule has wrapped to two lines in this e-mail, but in my config it is on one.
I have got an A record, zaphod-content.mydomain.com pointed at the IP Address that the Apache httpd server is listening on. In Zope, I have added a folder named zaphod-content.mydomain.com off of root. This has an index_html document in it.
When I connect to http://zaphod-content.mydomain.com I get the normal localhost:8080/ page. If I go to http://zaphod-content.mydomain.com/zaphod-content.mydomain.com I get what I expect to.
zaphod-content is not the primary name of this machine. The primary name is zaphod. Going to this also gives me the content I would expect to see at localhost:8080/
Any ideas why the contents of zaphod-content.mydomain.com are not being served as / when I request it as zaphod-content.mydomain.com ?
Well, it seems that your rule doesn't match. I would enable logging for mod_rewrite (see docs for how to do that) and see what the rewrite engine does. cheers, oliver
On 13/5/02 3:24 pm, "Oliver Bleutgen" <myzope@gmx.net> wrote:
<VirtualHost *> RewriteEngine On RewriteCond %{HTTP_HOST} ^.*$ RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/%{HTTP_HOST}:80/$1 [L,P]
This won't work when a client includes the port in the host header, like Host: zaphod-content.mydomain.com:80. Some clients do that, wget for instance, and you'll get an extra ":80" in your request to zope.
Ah, ok. The reason I did this is that the original had RewriteCond %{HTTP_HOST}:80 ^.*$ and this only worked if I included the :80 in my browser line.
<IfModule mod_proxy.c> ProxyRequests On
Are you sure you want that? You now have open your server as a proxy for the whole world, if no other access rules are installed. You don't need that for what you describe here, see http://httpd.apache.org/docs/mod/mod_proxy.html#proxyrequests
My main reason for including that is that the zope document I read at http://www.zope.org/Members/Jace/apache-vhm said I should include those lines. I shall remove it. Thanks for the tip :)
Any ideas why the contents of zaphod-content.mydomain.com are not being served as / when I request it as zaphod-content.mydomain.com ?
Well, it seems that your rule doesn't match. I would enable logging for mod_rewrite (see docs for how to do that) and see what the rewrite
I have done this at a rewriteloglevel of 3 and I get the following output: sd213.52.146.197 - - [13/May/2002:15:27:30 +0100] [zaphod-content.mydomain.com/sid#80dd578][rid#8134048/initial] (2) init rewrite engine with requested uri / 213.52.146.197 - - [13/May/2002:15:27:30 +0100] [zaphod-content.mydomain.com/sid#80dd578][rid#8134048/initial] (3) applying pattern '^/(.*)' to uri '/' 213.52.146.197 - - [13/May/2002:15:27:30 +0100] [zaphod-content.mydomain.com/sid#80dd578][rid#8134048/initial] (2) rewrite / -> http://127.0.0.1:8080/VirtualHostBase/http/zaphod-content.mydomain.com:80/ 213.52.146.197 - - [13/May/2002:15:27:30 +0100] [zaphod-content.mydomain.com/sid#80dd578][rid#8134048/initial] (2) forcing proxy-throughput with http://127.0.0.1:8080/VirtualHostBase/http/zaphod-content.mydomain.com:80/ This to me looks correct. The request is being translated to http://127.0.0.1:8080/VirtualHostBase/http/zaphod-content.mydomain.com:80/ Or is this not what it should be proxied to ? -- Wayne Pascoe <wayne.pascoe@ehsbrann.com> Give me enough medals, and I'll win any war. - Napolean
Sorry for me not sipping, I'am in a hurry... Wayne Pascoe wrote:
On 13/5/02 3:24 pm, "Oliver Bleutgen" <myzope@gmx.net> wrote:
<VirtualHost *> RewriteEngine On RewriteCond %{HTTP_HOST} ^.*$ RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/%{HTTP_HOST}:80/$1 [L,P]
This won't work when a client includes the port in the host header, like Host: zaphod-content.mydomain.com:80. Some clients do that, wget for instance, and you'll get an extra ":80" in your request to zope.
Ah, ok. The reason I did this is that the original had RewriteCond %{HTTP_HOST}:80 ^.*$ and this only worked if I included the :80 in my browser line.
Well, you need to do both, in one way or other. If you want the flexibility of variable HTTP_HOSTs, you need to cope with the fact that HTTP_HOST may be sent with or without the port tacked at the end of the hostname. This can be done with two RewriteConds + different following RewriteRules, something like (untested, wrapped) RewriteCond &{HTTP_HOST} ^.*:80$ RewriteRule http://127.0.0.1:8080/VirtualHostBase/http/%{HTTP_HOST}/$1 [L,P] RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/%{HTTP_HOST}:80/$1 [L,P] You should really read up about mod_rewrite, because, reading it again, I have no idea what effect your RewriteCond line should have. Seems to me it matches always. Here it filters if HTTP_HOST has a trailing ":80" and rewrites accordingly. If there's no trailing ":80" the second RewriteRule comes into effect. Thinking about it, I had emailed the author about this thing and it seems he just didn't quite adapt his howto correctly to the host-header "problem". The 3 lines above should do the trick.
<IfModule mod_proxy.c> ProxyRequests On
Are you sure you want that? You now have open your server as a proxy for the whole world, if no other access rules are installed. You don't need that for what you describe here, see http://httpd.apache.org/docs/mod/mod_proxy.html#proxyrequests
My main reason for including that is that the zope document I read at http://www.zope.org/Members/Jace/apache-vhm said I should include those lines. I shall remove it. Thanks for the tip :)
Once, I tried to contact the authors of the various apache+zope howtos which did do that wrong, but didn't find always contacts. It would be nice if you could inform that guy about this problem.
Any ideas why the contents of zaphod-content.mydomain.com are not being served as / when I request it as zaphod-content.mydomain.com ?
Well, it seems that your rule doesn't match. I would enable logging for mod_rewrite (see docs for how to do that) and see what the rewrite
I have done this at a rewriteloglevel of 3 and I get the following output:
sd213.52.146.197 - - [13/May/2002:15:27:30 +0100] [zaphod-content.mydomain.com/sid#80dd578][rid#8134048/initial] (2) init rewrite engine with requested uri / 213.52.146.197 - - [13/May/2002:15:27:30 +0100] [zaphod-content.mydomain.com/sid#80dd578][rid#8134048/initial] (3) applying pattern '^/(.*)' to uri '/' 213.52.146.197 - - [13/May/2002:15:27:30 +0100] [zaphod-content.mydomain.com/sid#80dd578][rid#8134048/initial] (2) rewrite / -> http://127.0.0.1:8080/VirtualHostBase/http/zaphod-content.mydomain.com:80/ 213.52.146.197 - - [13/May/2002:15:27:30 +0100] [zaphod-content.mydomain.com/sid#80dd578][rid#8134048/initial] (2) forcing proxy-throughput with http://127.0.0.1:8080/VirtualHostBase/http/zaphod-content.mydomain.com:80/
This to me looks correct. The request is being translated to http://127.0.0.1:8080/VirtualHostBase/http/zaphod-content.mydomain.com:80/
Or is this not what it should be proxied to ?
Ahh, now I see. No it isn't the right thing to do. Darn, forget the rules I wrote above, but the concept still holds. You should rewrite to http://127.0.0.1:8080/zaphod-content.mydomain.comVirtualHostBase/http/zaphod... with a VHM in the folder zaphod-content.mydomain.com. This is, because you still have to get into the right folder in zope, that work isn't done by VHM. To do that with the flexibility of HTTP_HOST - so it would work with any A record of your domain just by creating a folder with the right name and a VHM in it - needs some work with the HTTP_HOST cause of the ":80-problem". But if you have one static host and filter the subdomains via other means (say apache name-based VirtualHosts), and you have just one hostname per virtual host, one line is enough: RewriteRule ^/(.*) http://localhost:40080/zaphod-content.mydomain.com/VirtualHostBase/http/zaph... For further needs, I recommend reading up about mod_rewrite on httpd.apache.org. cheers, oliver
participants (2)
-
Oliver Bleutgen -
Wayne Pascoe