Forum Moderators: phranque

Message Too Old, No Replies

proxy redirect with pathing

         

cfchang11

2:17 am on Jul 7, 2004 (gmt 0)



Hi,

I'm trying to use my apache web server to proxy to another web server 's files. This is my config.

<VirtualHost 10.106.10.2:8080>
DocumentRoot /opt/crs-log
ServerName prod.abc
ErrorLog logs/prod--error_og
CustomLog logs/prod--access_log common
ProxyRequests off
ProxyPass /test [new-app1:8080...]
</VirtualHost>

When i use the URL :

[10.106.10.2:8080...]

i get proxy to the new-app1 web server's document root with all the files i wanted to access ( all text files). But when i click on the file to open, it fails, cos the URL is now :

[10.106.10.2:8080...]

where xyz.txt is the file on new-app1 that i wanted to see.

but if i change the URL to [10.106.10.2:8080...]

I can see the contents.

Is there anyway that i can make the redirect with the pathing as well?

gergoe

11:23 am on Jul 7, 2004 (gmt 0)

10+ Year Member



This is the expected behavior if you don't use the ProxyPassReverse directive. If you map some content under a subdirectory, and you're being linked to /something (from the mapped subdirectory) then your broswer will send the request to www.domain.com/something (not to the mapped subdir), so this request will not be mapped anymore. See the ProxyPassReverse documentation [httpd.apache.org] for details how to fix this.

It could be that even adding this directive does not solve the problem, especially if there are absolute links on the target website. Let's take an example:
Step 1.) Request for www.domain1.com/test/index.html
Step 2.) Apache turns the request to www.domain2.com/index.html and the response is sent back to the browser
Step 3.) If there's a resource with an absolute reference (like /image.gif) on the returned page, then the browser will send the request for www.domain1.com/image.gif because of the trailing slash, so this request will NOT be passed to the other host. But of course if you explicitly send the request for www.domain1.com/test/image.gif it will be processed properly.