It is not working only in Apache 2.2.4/CentOS. It is working in Apache 2.2.14/Ubuntu Just wanted to know if its bug or problem in my config. If its bug, how can I know.
On Mon, Feb 13, 2012 at 9:46 PM, Hridayesh Gupta <hridayeshi...@gmail.com>wrote: > Thanks for the reply. > > Actually my requirement is more complex and it needs dynamic proxying > based on mapping from mysql db. Thats why I used RewriteRule and > RewriteMap. One silly thing was not working so i tried this simple config > to test the problem. > > Based on ProxyPassReverse rules I have specified, Location header received > by Apache is translated as follows > 1. http://example.com/target/b --> /source/b : which is as expected > 2. http://example.com/target --> /target : which is not I am expecting. I > am expecting /source. > > Thank you > > > On Mon, Feb 13, 2012 at 9:30 PM, Tom Evans <tevans...@googlemail.com>wrote: > >> On Mon, Feb 13, 2012 at 11:35 AM, Hridayesh Gupta >> <hridayeshi...@gmail.com> wrote: >> > I have the following rule in conf file at server.com >> > >> > RewriteEngine On >> > RewriteRule /source(.*) http://example.com/target$1 [P] >> > ProxyRequests Off >> > ProxyPassReverse /source http://example.com/target >> > >> > http://example.com/target/a.php redirects to >> http://example.com/target/b.php >> > http://example.com/target redirects to http://example.com/target/ >> > >> > When I visit http://server.com/source/a.php , it redirects correctly to >> > http://server.com/source/b.php which will serve the content from >> > http://example.com/target/b.php as defined in rewriterule, But when I >> visit >> > http://server.com/source , it does not redirect to >> http://server.com/source/ >> > instead it redirects to http://server.com/target/ >> > The above worked correctly on my local machine Apache 2.2.14/Ubuntu with >> > same setting. >> > >> > I also have checked Location header using firbug while visiting >> > http://example.com/target and http://example.com/target/a.php and in >> both >> > cases Location header string is full url eg http://example.com/target/and >> > http://example.com/b.php >> > >> > So In my understanding ProxyPassReverse is not substituting Location >> header >> > correctly in Apache 2.2.4/CentOS >> > >> > Please help me for this issue. Please let me for any further >> information. >> > >> > Thank you >> >> You seem to be very confused about rewriting and proxying. First of >> all, when you wish to do proxying like in your example, you do not use >> a RewriteRule. You wrote: >> >> RewriteRule /source(.*) http://example.com/target$1 [P] >> >> This is equivalent to: >> >> ProxyPass /source http://example.com/target >> >> You're also proxying stuff you probably didn't intend either - eg >> /source-wibble will get proxied to http://example.com/target-wibble. >> It's best to include a trailing '/' where it is appropriate: >> >> ProxyPass /source/ http://example.com/target/ >> >> In fact, it is easier to combine all of this into a Location block: >> >> <Location /source/> >> ProxyPass http://example.com/target/ >> ProxyPassReverse http://example.com/target/ >> </Location> >> >> which is equivalent to your config. >> >> Now, your question is "why doesn't ProxyPassReverse do what I was >> expecting". You have: >> >> ProxyPassReverse /source http://example.com/target >> >> What this means is that when a response is received by apache from the >> http://example.com/target backend with a Location header, it will >> rewrite it. If the location header says "http://example.com/target/b", >> then it will get rewritten to "/source/b", and then turned into a >> absolute URI by Apache. >> >> If you truly believe that it is a bug in Apache causing this, then you >> will need to track it down. tcpdump showing the incoming request to >> the proxy, the outgoing request that this caused to the backend, the >> response the backend generates and the response that the proxy >> ultimately generates should show what is really happening. >> >> Cheers >> >> Tom >> >> --------------------------------------------------------------------- >> 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-unsubscr...@httpd.apache.org >> " from the digest: users-digest-unsubscr...@httpd.apache.org >> For additional commands, e-mail: users-h...@httpd.apache.org >> >> >