I am trying to figure this out and I always seem to have trouble configuring apache to do more than basic stuff...
I have a web server that has several cnames assigned to it.
I want srv1.tobyhouse.com to be served by apache. I want to proxy connections to www.tobyhouse.com to cms.tobyhouse.com (different system)
If I do this...
<VirtualHost www.tobyhouse.com:*> ProxyPass / http://cms.tobyhouse.com ProxyPassReverse / http://cms.tobyhouse.com </VirtualHost>
then I am good but it seemed to not pull the assets like css and javascripts from cms.tobyhouse.com
When I did this...
<VirtualHost www.tobyhouse.com:*> RedirectPermanent / http://cms.tobyhouse.com </VirtualHost>
It sent ALL traffic over to the other server which is clearly not what I want.
How can handle this? Must I give a unique ip address to www.tobyhouse.com?
Craig
Craig White wrote:
I am trying to figure this out and I always seem to have trouble configuring apache to do more than basic stuff...
I have a web server that has several cnames assigned to it.
I want srv1.tobyhouse.com to be served by apache. I want to proxy connections to www.tobyhouse.com to cms.tobyhouse.com (different system)
If I do this...
<VirtualHost www.tobyhouse.com:*> ProxyPass / http://cms.tobyhouse.com ProxyPassReverse / http://cms.tobyhouse.com
</VirtualHost>
then I am good but it seemed to not pull the assets like css and javascripts from cms.tobyhouse.com
That should work - but I'd put a trailing / on the target. The files that don't appear to work are probably cached in your browser or an intermediate cache. Check the logs to see if a request even came in. You can get finer-grained control by using rewriterules with the P flag but you shouldn't need it. Just make sure the links from the backend server are all relative and don't mention its real hostname.
On Mon, 2008-05-05 at 17:08 -0500, Les Mikesell wrote:
Craig White wrote:
I am trying to figure this out and I always seem to have trouble configuring apache to do more than basic stuff...
I have a web server that has several cnames assigned to it.
I want srv1.tobyhouse.com to be served by apache. I want to proxy connections to www.tobyhouse.com to cms.tobyhouse.com (different system)
If I do this...
<VirtualHost www.tobyhouse.com:*> ProxyPass / http://cms.tobyhouse.com ProxyPassReverse / http://cms.tobyhouse.com
</VirtualHost>
then I am good but it seemed to not pull the assets like css and javascripts from cms.tobyhouse.com
That should work - but I'd put a trailing / on the target. The files that don't appear to work are probably cached in your browser or an intermediate cache. Check the logs to see if a request even came in. You can get finer-grained control by using rewriterules with the P flag but you shouldn't need it. Just make sure the links from the backend server are all relative and don't mention its real hostname.
---- OK - well adding the backslash to the end seemed to fix the issue with css but the problem is that stuff that is going to srv1.tobyhouse.com is also proxied over to the same site and I want that to stay at home.
So it still is a problem
Craig
On Mon, May 05, 2008 at 03:14:35PM -0700, Craig White wrote:
On Mon, 2008-05-05 at 17:08 -0500, Les Mikesell wrote:
Craig White wrote:
<VirtualHost www.tobyhouse.com:*> ProxyPass / http://cms.tobyhouse.com ProxyPassReverse / http://cms.tobyhouse.com
</VirtualHost>
That should work - but I'd put a trailing / on the target. The files
OK - well adding the backslash to the end seemed to fix the issue with css but the problem is that stuff that is going to srv1.tobyhouse.com is also proxied over to the same site and I want that to stay at home.
Try putting a "ServerName www.tobyhouse.com" entry into the VirtualHost config.
Stephen Harris wrote:
On Mon, May 05, 2008 at 03:14:35PM -0700, Craig White wrote:
On Mon, 2008-05-05 at 17:08 -0500, Les Mikesell wrote:
Craig White wrote:
<VirtualHost www.tobyhouse.com:*> ProxyPass / http://cms.tobyhouse.com ProxyPassReverse / http://cms.tobyhouse.com
</VirtualHost>
That should work - but I'd put a trailing / on the target. The files
OK - well adding the backslash to the end seemed to fix the issue with css but the problem is that stuff that is going to srv1.tobyhouse.com is also proxied over to the same site and I want that to stay at home.
Try putting a "ServerName www.tobyhouse.com" entry into the VirtualHost config.
I missed that - the name in the VirtualHost directive will just be evaluated as an IP address. To actually identify a named virtual host the ServerName must match what the client sends the the Host: header. ServerName can only have one entry. If there are more names this host should accept you can have a ServerAlias entry with multiple names. If none of your virtualhost entries have a match and you don't have an explict default, the first one is used.
On Mon, 2008-05-05 at 17:27 -0500, Les Mikesell wrote:
Stephen Harris wrote:
On Mon, May 05, 2008 at 03:14:35PM -0700, Craig White wrote:
On Mon, 2008-05-05 at 17:08 -0500, Les Mikesell wrote:
Craig White wrote:
<VirtualHost www.tobyhouse.com:*> ProxyPass / http://cms.tobyhouse.com ProxyPassReverse / http://cms.tobyhouse.com
</VirtualHost>
That should work - but I'd put a trailing / on the target. The files
OK - well adding the backslash to the end seemed to fix the issue with css but the problem is that stuff that is going to srv1.tobyhouse.com is also proxied over to the same site and I want that to stay at home.
Try putting a "ServerName www.tobyhouse.com" entry into the VirtualHost config.
I missed that - the name in the VirtualHost directive will just be evaluated as an IP address. To actually identify a named virtual host the ServerName must match what the client sends the the Host: header. ServerName can only have one entry. If there are more names this host should accept you can have a ServerAlias entry with multiple names. If none of your virtualhost entries have a match and you don't have an explict default, the first one is used.
---- yeah...I ended up...
NameVirtualHost *:80 <VirtualHost *:80> ServerName www.tobyhouse.com ProxyTimeout 10000 ProxyPass / http://cms.tobyhouse.com/ ProxyPassReverse / http://cms.tobyhouse.com/ </VirtualHost>
<VirtualHost *:80> ServerName srv1.tobyhouse.com DocumentRoot /var/www/html </VirtualHost>
awesome...thanks Les/Stephen - I can now take my time and figure out what we're going to do before I make any DNS changes
Craig
Craig White wrote on Mon, 05 May 2008 14:57:05 -0700:
<VirtualHost www.tobyhouse.com:*>
this is very old-fashioned and unreliable syntax, use this instead: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
RedirectPermanent / http://cms.tobyhouse.com
It sent ALL traffic over to the other server which is clearly not what I want.
I don't understand. Isn't that exactly what you want, redirect all traffic for www.tobyhouse.com to cms.tobyhouse.com?
How can handle this? Must I give a unique ip address to www.tobyhouse.com?
Ah, you have several virtual hosts on it and all of them get redirected to cms.tobyhouse.com? That's the result of the wrong virtual host syntax you use. Use name-based virtual hosts and it will work.
Why don't you solve this at dns level? Wouldn't that be much "cleaner"?
Kai
On Tue, 2008-05-06 at 01:31 +0200, Kai Schaetzl wrote:
Craig White wrote on Mon, 05 May 2008 14:57:05 -0700:
<VirtualHost www.tobyhouse.com:*>
this is very old-fashioned and unreliable syntax, use this instead: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
---- that's what I ended up doing...you took the first message in the thread ----
RedirectPermanent / http://cms.tobyhouse.com
It sent ALL traffic over to the other server which is clearly not what I want.
I don't understand. Isn't that exactly what you want, redirect all traffic for www.tobyhouse.com to cms.tobyhouse.com?
How can handle this? Must I give a unique ip address to www.tobyhouse.com?
Ah, you have several virtual hosts on it and all of them get redirected to cms.tobyhouse.com? That's the result of the wrong virtual host syntax you use. Use name-based virtual hosts and it will work.
Why don't you solve this at dns level? Wouldn't that be much "cleaner"?
---- sure - but I needed a way to do this temporarily to demonstrate to bosses who don't always understand these technical issues and to figure out if and how I handle things at the DNS level.
Craig
Craig White wrote:
On Tue, 2008-05-06 at 01:31 +0200, Kai Schaetzl wrote:
Craig White wrote on Mon, 05 May 2008 14:57:05 -0700:
<VirtualHost www.tobyhouse.com:*>
this is very old-fashioned and unreliable syntax, use this instead: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
that's what I ended up doing...you took the first message in the thread
RedirectPermanent / http://cms.tobyhouse.com It sent ALL traffic over to the other server which is clearly not what I want.
I don't understand. Isn't that exactly what you want, redirect all traffic for www.tobyhouse.com to cms.tobyhouse.com?
How can handle this? Must I give a unique ip address to www.tobyhouse.com?
Ah, you have several virtual hosts on it and all of them get redirected to cms.tobyhouse.com? That's the result of the wrong virtual host syntax you use. Use name-based virtual hosts and it will work.
Why don't you solve this at dns level? Wouldn't that be much "cleaner"?
sure - but I needed a way to do this temporarily to demonstrate to bosses who don't always understand these technical issues and to figure out if and how I handle things at the DNS level.
Its actually very useful to access backend hosts on private networks or to transparently spread the load across several machines.
Les Mikesell wrote on Mon, 05 May 2008 23:49:11 -0500:
Its actually very useful to access backend hosts on private networks or to transparently spread the load across several machines.
If you proxy it, not with a Redirect, yes. It seemed he wanted just a redirect.
Kai
On Tue, 2008-05-06 at 11:31 +0200, Kai Schaetzl wrote:
Les Mikesell wrote on Mon, 05 May 2008 23:49:11 -0500:
Its actually very useful to access backend hosts on private networks or to transparently spread the load across several machines.
If you proxy it, not with a Redirect, yes. It seemed he wanted just a redirect.
---- I wanted to proxy it...I was willing to accept a redirect as a temporary measure.
Thanks all
Craig
Craig White wrote on Mon, 05 May 2008 16:38:00 -0700:
that's what I ended up doing...you took the first message in the thread
I see. That message wasn't here when I wrote that.
Kai