For those interested, I ended up using different ports to achieve the desired result. There may be a better way but this works for me:
Server 1
<VirtualHost *:80>
       ServerName server.mydomain.com
       RewriteEngine On
       RewriteRule ^/(.*) http://60.234.nnn.nn:8008/$1 [L,P]
</VirtualHost>
<VirtualHost *:80>
       ServerName otherserver.mydomain.com
       RewriteEngine On
       RewriteRule ^/(.*) http://60.234.nnn.nn:8081/$1 [L,P]
</VirtualHost>

Server 2
NameVirtualHost *:8008
NameVirtualHost *:8081
<VirtualHost *:8008>
       ServerName server.mydomain.com
       RewriteEngine On
       RewriteRule ^/(.*)      http://server.mydomain.com/$1 [L,R]
       DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:8081>
       ServerName otherserver.mydomain.com
       RewriteEngine On
       RewriteRule ^/(.*)      http://otherserver.mydomain.com/$1 [L,R]
       DocumentRoot /var/www/html2
</VirtualHost>

Regards

Cameron

----- Original Message ----- From: "Boyle Owen" <[EMAIL PROTECTED]>
To: <users@httpd.apache.org>
Sent: Tuesday, June 28, 2005 8:38 PM
Subject: RE: [EMAIL PROTECTED] RewriteRule question: forward requests from one Apache server to another


-----Original Message-----
From: Cameron Beattie [mailto:[EMAIL PROTECTED]
Sent: Dienstag, 28. Juni 2005 10:15
To: users@httpd.apache.org
Subject: Re: [EMAIL PROTECTED] RewriteRule question: forward requests from
one Apache server to another


Ok so I checked httpd.conf on server 1 and I stupidly hadn't included
RewriteEngine On. I've done that and now I get served up a
site from server
2, but it's the wrong site.

I have two virtual hosts set up as follows:

Server 1
NameVirtualHost *:80

<VirtualHost *:80>
        ServerName server.mydomain.com
        RewriteEngine On
        RewriteRule ^/(.*) http://60.234.nnn.nn:8008/$1 [L,P]
</VirtualHost>
<VirtualHost *:80>
        ServerName otherserver.mydomain.com
        RewriteEngine On
        RewriteRule ^/(.*) http://60.234.nnn.nn:8008/$1 [L,P]
</VirtualHost>

Server2
NameVirtualHost *:8008

<VirtualHost *:8008>
        ServerName server.mydomain.com
        DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:8008>
        ServerName otherserver.mydomain.com
        DocumentRoot /var/www/html2
</VirtualHost>

When I browse to http://otherserver.mydomain.com I get served up the
http://server.mydomain.com site. This is the same site that I
get served if
I browse to http://serveripaddress:8080. So I don't think the
host header is
being passed properly from server 1 to server 2.

Why do you imagine it would?

You've told apache that if it receives a request for otherserver.mydomain.com, to make a new different request for http://60.234.nnn.nn:8008/. So the internal server sees a request which doesn't even have a hostname header (you're using an IP in the rewrite).

To do it the way you want to, you'll have to give names to the internal sites (mapping to the 60.234.nn.nnn IP) and then refer to them by name in the RewriteRule.

Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored.



Any suggestions?




Regards

Cameron

----- Original Message ----- From: "Boyle Owen" <[EMAIL PROTECTED]>
To: <users@httpd.apache.org>
Sent: Tuesday, June 28, 2005 6:58 PM
Subject: RE: [EMAIL PROTECTED] RewriteRule question: forward
requests from one
Apache server to another


> -----Original Message-----
> From: Cameron Beattie [mailto:[EMAIL PROTECTED]
> Sent: Dienstag, 28. Juni 2005 04:50
> To: users@httpd.apache.org
> Subject: [EMAIL PROTECTED] RewriteRule question: forward
requests from one
> Apache server to another
>
>
> I am trying to set up the following configuration:
> 1. Apache server with public IP address
> 2. Apache server behind NAT with no public IP address
> 3. Router with public IP address with port forwarding set up
> for port 8008
> to Apache server 2
> 4. Public DNS record server.mydomain.com resolves to IP
> address of server 1
>
> When a user browses to server.mydomain.com I want a web site
> to be served up
> from from server 2.
>
> I have set the following up in httpd.conf on server 1:
> <VirtualHost *:80>
>         ServerName server.mydomain.com
>         RewriteEngine On
>         RewriteRule ^/(.*) http://60.234.nnn.nn:8008/$1 [L,P]
> </VirtualHost>
>
> I have set the following up in httpd.conf on server 2:
> <VirtualHost *:8008>
>     ServerName server.mydomain.com
>     DocumentRoot /var/www/html
> </VirtualHost>
>
> I can access the website locally by accessing the site on
> server 2, but not
> through server 1. If I enter http://server.mydomain.com I
> just get the
> default apache homepage, rather than the index.phtml page
> that I want to be
> served up. If I enter  http://server.mydomain.com/index.phtml
> I get a 404
> error.

I guess you left the usual doc-root pointing to htdocs in the
main part of
the config (outside the VH).
So if you get the default page then it's not the RewriteRule
- the request
is not getting into the VH container.

Did you do:

NameVirtualHost *:80

to tell apache to use name-based virtual-hosting?

Before worrying about rewriting, get the VH working: comment
out the Rewrite
rules, stick a temporary docroot in the VH container and
check you can hit
it.

Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored.

>
> I guess my rewriterule is wrong but I'm not sure how to fix
> it. Any help
> would be appreciated.
>
> Regards
>
> Cameron
>
>
>
---------------------------------------------------------------------
> 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: [EMAIL PROTECTED]
>    "   from the digest: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
Diese E-mail ist eine private und persönliche Kommunikation.
Sie hat keinen
Bezug zur Börsen- bzw. Geschäftstätigkeit der SWX Gruppe.
This e-mail is of
a private and personal nature. It is not related to the
exchange or business
activities of the SWX Group. Le présent e-mail est un message
privé et
personnel, sans rapport avec l'activité boursière du Groupe SWX.


This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any
mistransmission. If
you receive this message in error, please notify the sender
urgently and
then immediately delete the message and any copies of it from
your system.
Please also immediately destroy any hardcopies of the
message. You must not,
directly or indirectly, use, disclose, distribute, print, or
copy any part
of this message if you are not the intended recipient. The
sender's company
reserves the right to monitor all e-mail communications through their
networks. Any views expressed in this message are those of
the individual
sender, except where the message states otherwise and the sender is
authorised to state them to be the views of the sender's company.

---------------------------------------------------------------------
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: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
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: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please notify the sender urgently and then immediately delete the message and any copies of it from your system. Please also immediately destroy any hardcopies of the message. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. The sender's company reserves the right to monitor all e-mail communications through their networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of the sender's company.

---------------------------------------------------------------------
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: [EMAIL PROTECTED]
  "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
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: [EMAIL PROTECTED]
  "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to