The reason for this setup is so that each instance can be accessed from the browser without the need to remember port numbers, and without the port numbers being displayed in the address bar.
The instances all have a DNS entry pointing to the server IP e.g
192.168.0.1 proxy (Running on port 80)
192.168.0.1 server1 (Running on port 8001)
192.168.0.1 server2 (Running on port 8002)
The setup is working almost flawlessly, but I have one problem with trailing forward slashes.
If I enter http://server1 in the address bar I get forwarded on to 192.168.0.1:8001. This is correct, the address bar is also correct just showing http://server1
I have a sub directory under server1 called 'something', If I enter http://server1/something/ (note the forward slash) in the address bar I get forwarded on to 192.168.0.1:8001/something. This is correct, the address bar is also correct just showing http://server1/something/
But if drop the forward slash, just enter http://server1/something in the address bar I get forwarded on to 192.168.0.1:8001/something. This is correct, but the address bar is wrong, showing http://server1:8001/something/
I don't know why it's added the port number in this instance.
The following is my rewrite rule
- Code: Select all
RewriteEngine on
RewriteLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/proxy/rewrite.log"
RewriteLogLevel 3
RewriteCond %{HTTP_HOST} ^server1$ [NC]
RewriteRule ^/(.*) http://server1:8001/$1 [L,P]
I'm aware that this may not be a rewrite problem, but wanted to check here first.
The rewrite log is showing an OK status for each request too. Here's what the log shows for both requests...
- Code: Select all
192.168.0.1 - - [10/Jul/2009:17:41:26 +0100] [server1/sid#5a7a80][rid#2cf4120/initial] (2) init rewrite engine with requested uri /something
192.168.0.1 - - [10/Jul/2009:17:41:26 +0100] [server1/sid#5a7a80][rid#2cf4120/initial] (3) applying pattern '^/(.*)' to uri '/something'
192.168.0.1 - - [10/Jul/2009:17:41:26 +0100] [server1/sid#5a7a80][rid#2cf4120/initial] (2) rewrite '/something' -> 'http://server1:8001/something'
192.168.0.1 - - [10/Jul/2009:17:41:26 +0100] [server1/sid#5a7a80][rid#2cf4120/initial] (2) forcing proxy-throughput with http://server1:8001/something
192.168.0.1 - - [10/Jul/2009:17:41:26 +0100] [server1/sid#5a7a80][rid#2cf4120/initial] (1) go-ahead with proxy request proxy:http://server1:8001/something [OK]
192.168.0.1 - - [10/Jul/2009:17:41:35 +0100] [server1/sid#5a7a80][rid#2d04578/initial] (2) init rewrite engine with requested uri /something/
192.168.0.1 - - [10/Jul/2009:17:41:35 +0100] [server1/sid#5a7a80][rid#2d04578/initial] (3) applying pattern '^/(.*)' to uri '/something/'
192.168.0.1 - - [10/Jul/2009:17:41:35 +0100] [server1/sid#5a7a80][rid#2d04578/initial] (2) rewrite '/something/' -> 'http://server1:8001/something/'
192.168.0.1 - - [10/Jul/2009:17:41:35 +0100] [server1/sid#5a7a80][rid#2d04578/initial] (2) forcing proxy-throughput with http://server1:8001/something/
192.168.0.1 - - [10/Jul/2009:17:41:35 +0100] [server1/sid#5a7a80][rid#2d04578/initial] (1) go-ahead with proxy request proxy:http://server1:8001/something/ [OK]
If this is to do with the setup of the virtual host on the destination server then I can post that info too. Do I need some kind of a rewrite rule on the destination server?
Sorry for the long post.
Regards
Rich