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've a situation where I want to redirect everything that starts with /app to an internal server. Basically the idea is that Apache will work as a reverse proxy doing the following conversion:

http://external/app -> http://myserver:1082/myapp

I was able to do it using Rewrite, as follows:

  RewriteCond %{REQUEST_URI} ^/app
  RewriteRule ^/app(.*)$ http://myserver:1082/myapp$1 [L,P]

  ProxyPassReverse /app http://myserver:1082/myapp

It works fine. The issue is that now I'm gonna have a language preffix on the URL, but no on the application. So I need the following redirection:

http://external/app -> http://myserver:1082/myapp
http://external/en/app -> http://myserver:1082/myapp
http://external/pt/app -> http://myserver:1082/myapp

While this can be done with the rewrite, I have a problem with the proxyPassReverse. Because basically I need to do a dynamic ProxyPassRever that, depending on the actual URL request by the user, changes the Location

ProxyPassReverse /en/app http://myserver:1082/myapp
ProxyPassReverse /pt/app http://myserver:1082/myapp
ProxyPassReverse /app http://myserver:1082/myapp

It would be something like

ProxyPassReverse ${preffix}/app http://myserver:1082/myapp

Is it possible to do that?

share|improve this question
add comment

1 Answer

From ProxyPathReverse:

When used inside a section, the first argument is omitted and the local directory is obtained from the .

From Location:

The URL may use wildcards. In a wild-card string, ? matches any single character, and * matches any sequences of characters. Extended regular expressions can also be used, with the addition of the ~ character.

So you should be able to use:

<Location /[a-z]+/app>
    ProxyPathReverse http://myserver:1082/myapp
</Location>
share|improve this answer
1  
Actually, that does not work, since it replaces "myserver:1082/myapp"; for the literal string "/[a-z]+", instead of using the actual path that matched the regular expression –  Jose L Martinez-Avial Jul 7 '12 at 16:38
    
Where does it do this replacement? –  Pierre Carrier Jul 7 '12 at 17:04
1  
On the affected headers on the response. –  Jose L Martinez-Avial Jul 7 '12 at 17:19
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.