Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a backend server running on http://10.0.2.20/ from the local network, which serves similar to this:

/ (root)
|
|_user1/
| |_www/
| |_private/
|
|_user2/
  |_www/
  |_private/
(etc.)

Accessing http://10.0.2.20/user1/ of course, contains 'www' and 'private' folders and is proxied through a public server using Apache's Reverse Proxy. I'd like it so the following happens:

http://public-proxy-server/user1/ actually shows the content from http://10.0.2.20/user1/www/ without indicating it in the URL. (/private/ would not be accessible via the public proxy server).

The key here, is for it to be dynamic, so all requests to http://public-proxy-server/*/should show content from http://10.0.2.20/*/www/. Again, the proxy currently works fine; below is the config:

(On the public server)

<VirtualHost *:80>
        ServerName www.domain.com
        ProxyRequests Off
        ProxyPreserveHost On
        ProxyVia full
        ProxyPass / http://10.0.2.20/
        ProxyPassReverse / http://10.0.2.20/
</VirtualHost>

(On the backend server)

<VirtualHost *:80>
        ...
        #this directory contains folders 'user1' and 'user2'
        DocumentRoot /var/www/
        ...
</VirtualHost>
share|improve this question
    
Is there content that depends on 30x redirects to function (in other words; do you actually need that ProxyPassReverse)? And how about content (images, CSS, javascript) that are linked with absolute paths from the content? –  Shane Madden Sep 22 '12 at 19:38
    
Well it's simply just proxying the content from an internal server, all files (images, stylesheets, etc) are served like it would be externally. There's no need to 'redirect' per se, but just 'rewrite' the URL internally. That's all I'm going for. To serve the content of the '/user/www' folder without showing the 'www' in the URL. The only (and main) problem is the wildcard. Basically I need the DocumentRoot on the proxy server to be set to /username/www (append the www). It doesn't matter if that happens on the public or proxy server. Am I making any sense? –  ionFish Sep 23 '12 at 1:12
add comment

1 Answer 1

up vote 2 down vote accepted

On the reverse proxy server, use a ProxyPassMatch:

ProxyPassMatch ^/([^/]+)/(.*)$ http://10.0.2.20/$1/www/$2

And you'll probably still want the / root proxying, so keep that ProxyPass in place - just make sure it's below the ProxyPassMatch, since they're checked in order.

share|improve this answer
    
Ah, finally. Worked as intended. I was trying mod_rewrite and related. Even the [P] flag. –  ionFish Sep 24 '12 at 10:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.