RE: [users@httpd] RewriteRule question: forward requests from one Apache server to another

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Cameron Beattie [mailto:kjcsb@xxxxxxxxxxxx]
> Sent: Mittwoch, 29. Juni 2005 07:17
> To: users@xxxxxxxxxxxxxxxx
> Subject: Re: [users@httpd] RewriteRule question: forward requests from
> one Apache server to another
> 
> 
> 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:

That's fine if you're happy with it, but just to be clear; server 2 now serves two port-based VHs. It is no longer a name-based VH server. So you don't need the NameVirtualHost or ServerName directives. Bear this in mind just in case in future you add a name-based VH to server 2 and wonder why it don't work...

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

> 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" <Owen.Boyle@xxxxxxx>
> To: <users@xxxxxxxxxxxxxxxx>
> Sent: Tuesday, June 28, 2005 8:38 PM
> Subject: RE: [users@httpd] RewriteRule question: forward 
> requests from one 
> Apache server to another
> 
> 
> > -----Original Message-----
> > From: Cameron Beattie [mailto:kjcsb@xxxxxxxxxxxx]
> > Sent: Dienstag, 28. Juni 2005 10:15
> > To: users@xxxxxxxxxxxxxxxx
> > Subject: Re: [users@httpd] 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" <Owen.Boyle@xxxxxxx>
> > To: <users@xxxxxxxxxxxxxxxx>
> > Sent: Tuesday, June 28, 2005 6:58 PM
> > Subject: RE: [users@httpd] RewriteRule question: forward
> > requests from one
> > Apache server to another
> >
> >
> > > -----Original Message-----
> > > From: Cameron Beattie [mailto:kjcsb@xxxxxxxxxxxx]
> > > Sent: Dienstag, 28. Juni 2005 04:50
> > > To: users@xxxxxxxxxxxxxxxx
> > > Subject: [users@httpd] 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: users-unsubscribe@xxxxxxxxxxxxxxxx
> > >    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> > > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> > >
> > >
> > 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: users-unsubscribe@xxxxxxxxxxxxxxxx
> >    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> >
> >
> > 
> ---------------------------------------------------------------------
> > 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@xxxxxxxxxxxxxxxx
> >    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> >
> >
> 
> 
> 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: users-unsubscribe@xxxxxxxxxxxxxxxx
>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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@xxxxxxxxxxxxxxxx
>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> 
>
 
 
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: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux