httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Krist van Besien" <krist.vanbes...@gmail.com>
Subject Re: [users@httpd] Rewrite Rule Help
Date Thu, 22 May 2008 14:21:47 GMT
On Thu, May 22, 2008 at 3:35 PM, Scott Moseman <scmoseman@gmail.com> wrote:
>> Could yo ube more specific? Is the web application configured with /
>> as base URL or with /portal/ as base URL? Do you want to hide the
>> "/portal" path for your users, of for the web application?
>
> Maybe my proxy configuration will give you more of an idea.  The site
> has a custom port and /portal path, both of which we're trying to hide
> through the proxy.  The RewriteRule was necessary because there's
> references to absolutely paths in some of the code.
>
>  ProxyPass / http://remotehost:8080/portal/
>  ProxyPassReverse / http://removehost:8080/portal/

OK. You have an application that thinks it's base url is /portal, but
want your users to see it at /. That is indeed what reverse proxying
is for.

However, you apparently still have a few problems.
- ProxyPassReverse will only rewrite the URL in the content header
when the backend responds with a redirect. It will not change the body
of the response. So any absolute links that contain /portal/ will get
passed to the client, and the client will see "portal" in the URL bar
when he clicks on such a link. You try to get rid of these by
answering any request to /portal with a redirect, but this breaks
logging in. Am I correct?

What I suspect here is that your application sends a cookie, with a
cookie path of /portal. After the webclient gets redirected it will
not send the cookie back with it's request as it is not going to a URL
starting with /portal. This breaks your session.
If what I assume here is correct (you can verify that with any tool
that allows you to inspect cookies) you can solve this by adding:

ProxyPassReverseCookiePath  /portal /

This might be all you need, but maybe you also need to rewrite the
URLs in the body of the responses send by your application. For that
there exists a third party modules, about which you can read here:

http://www.apachetutor.org/admin/reverseproxies

This is however not something for an apache newbie.

>
>>> RewriteEngine On
>>> RewriteCond  %{REQUEST_URI}  ^/portal/(.*)
>>> RewriteRule  ^/portal/(.*)   /$1   [R]
>>
>> The rewriteCond is superfluous. The rewriterule will only match urls
>> starting with /portal...
>
> Ok.  I was under the impression I had to match a RewriteCond before
> the RewriteRule would be called.

The order of execution of RewriteRule and RewriteCond is a bit
peculiar. First the pattern of the Rewriterule gets matched. If this
matches then the RewriteCond above it gets executed. If that is
successful the URL is replaced with the replacement string in the
RewriteRule. This means that it is entirely superfluous to test for
the same pattern in a RewriteCond as in a RewriteRule. The details are
here:
http://httpd.apache.org/docs/2.2/rewrite/rewrite_tech.html

Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
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-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message