You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by ac...@softreset.de on 2010/04/14 11:10:36 UTC

[users@httpd] RewriteRule with [P] Flag

Dear all,


since quite some time every now and then (can i say that ;) )
i get stuck with a rewriting issue.

i would like to use the rewrite capabilities with the
proxy flag.

Example:
RewriteEngine on
RewriteRule ^(.*)$ http://localhost:9090/index.jsp [P]



Assume the server configured with the above example is 
reachable via https://inthewild.org.

A request to https://inthewild.org gets forwarded all right to
http://localhost:9090/index.jsp. The server on localhost:9090
itself does a http 302 (redirect) to 
http://localhost:9090/setup/login.jsp and returns that to
the browser.

The browser ends up with a not working URL:
http://localhost:9090/setup/login.jsp

I would like getting back URL's like this one:
https://inthewild.org/setup/login.jsp

Please point me to the right direction.



Thx, Axel


---------------------------------------------------------------------
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


Re: [users@httpd] RewriteRule with [P] Flag

Posted by Axel Christiansen <ac...@softreset.de>.
Am 16.04.2010 12:12, schrieb Krist van Besien:
> On Wed, Apr 14, 2010 at 11:10 AM,  <ac...@softreset.de> wrote:
> 
>> A request to https://inthewild.org gets forwarded all right to
>> http://localhost:9090/index.jsp. The server on localhost:9090
>> itself does a http 302 (redirect) to
>> http://localhost:9090/setup/login.jsp and returns that to
>> the browser.
>>
>> The browser ends up with a not working URL:
>> http://localhost:9090/setup/login.jsp
>>
>> I would like getting back URL's like this one:
>> https://inthewild.org/setup/login.jsp
>>
>> Please point me to the right direction.
> 
> What you need to do is look at the configuration of whatever it is you
> use on port 9090. You must configure that piece of software to issue
> redirects that use the right hostname. Often there is a "base url" or
> "base hostname" or something similar that you can set in your config.
> When running an application server behing a reverse proxy (a very
> common scenario) you should configure the application server as if it
> was running without a reverse proxy, as if it was the front end
> server. If you can't do that there are workarounds in volving
> proxypassrevers or even mod_proxy_html, but these are complicated. Try
> solving the problem at the source first.

Thank you. Yes that works. I was hoping to avoid setting
a base URL for more flexibility.


Axel







---------------------------------------------------------------------
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


Re: [users@httpd] RewriteRule with [P] Flag

Posted by Krist van Besien <kr...@gmail.com>.
On Wed, Apr 14, 2010 at 11:10 AM,  <ac...@softreset.de> wrote:

> A request to https://inthewild.org gets forwarded all right to
> http://localhost:9090/index.jsp. The server on localhost:9090
> itself does a http 302 (redirect) to
> http://localhost:9090/setup/login.jsp and returns that to
> the browser.
>
> The browser ends up with a not working URL:
> http://localhost:9090/setup/login.jsp
>
> I would like getting back URL's like this one:
> https://inthewild.org/setup/login.jsp
>
> Please point me to the right direction.

What you need to do is look at the configuration of whatever it is you
use on port 9090. You must configure that piece of software to issue
redirects that use the right hostname. Often there is a "base url" or
"base hostname" or something similar that you can set in your config.
When running an application server behing a reverse proxy (a very
common scenario) you should configure the application server as if it
was running without a reverse proxy, as if it was the front end
server. If you can't do that there are workarounds in volving
proxypassrevers or even mod_proxy_html, but these are complicated. Try
solving the problem at the source first.

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


Re: [users@httpd] RewriteRule with [P] Flag

Posted by Eric Covener <co...@gmail.com>.
On Wed, Apr 14, 2010 at 8:11 AM, Mark Watts <m....@eris.qinetiq.com> wrote:
> On Wed, 2010-04-14 at 08:03 -0400, Eric Covener wrote:
>> On Wed, Apr 14, 2010 at 6:32 AM,  <ac...@softreset.de> wrote:
>> > On Wed, 14 Apr 2010 05:44:26 -0400, Eric Covener <co...@gmail.com> wrote:
>> >>> RewriteRule ^(.*)$ http://localhost:9090/index.jsp [P]
>> >>
>> >>> The browser ends up with a not working URL:
>> >>> http://localhost:9090/setup/login.jsp
>> >>
>> >> http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse
>> >
>> > I did not mention in this case it is about a full managed
>> > Linux box. Access to the Apache config is not permitted.
>> > One hat to use a .htaccess file.
>> >
>> > Is there something similar to ProxyPassReverse which works
>> > in the .htaccess?
>>
>> Maybe 'Header edit Location ...' but I'm not sure if Header directives
>> in your htaccess will still be applicable after all the proxying work
>> is done (it wouldn't with ProxyPass, but it might since you had
>> mod_rewrite in htaccess)
>>
>>
>
> Eric - what makes [P] valid in an htaccess, but not
> ProxyPass/ProxyPassReverse ?
>

I'm just going by the manual.  They weren't implemented to be used in
that context, since a normal proxy request is never mapped to the
filesystem.

Proxy works over several hooks, and suppresses ever mapping anything
to disk.  In the case of rewrite in per-directory context, rewrite
kicks off the "latter" processing but bootstraps it a different way
(long after the resource has already been mapped to disk)


-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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


Re: [users@httpd] RewriteRule with [P] Flag

Posted by Mark Watts <m....@eris.qinetiq.com>.
On Wed, 2010-04-14 at 08:03 -0400, Eric Covener wrote:
> On Wed, Apr 14, 2010 at 6:32 AM,  <ac...@softreset.de> wrote:
> > On Wed, 14 Apr 2010 05:44:26 -0400, Eric Covener <co...@gmail.com> wrote:
> >>> RewriteRule ^(.*)$ http://localhost:9090/index.jsp [P]
> >>
> >>> The browser ends up with a not working URL:
> >>> http://localhost:9090/setup/login.jsp
> >>
> >> http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse
> >
> > I did not mention in this case it is about a full managed
> > Linux box. Access to the Apache config is not permitted.
> > One hat to use a .htaccess file.
> >
> > Is there something similar to ProxyPassReverse which works
> > in the .htaccess?
> 
> Maybe 'Header edit Location ...' but I'm not sure if Header directives
> in your htaccess will still be applicable after all the proxying work
> is done (it wouldn't with ProxyPass, but it might since you had
> mod_rewrite in htaccess)
> 
> 

Eric - what makes [P] valid in an htaccess, but not
ProxyPass/ProxyPassReverse ?

Mark.

-- 
Mark Watts BSc RHCE MBCS
Senior Systems Engineer, Managed Services Manpower
www.QinetiQ.com
QinetiQ - Delivering customer-focused solutions
GPG Key: http://www.linux-corner.info/mwatts.gpg

Re: [users@httpd] RewriteRule with [P] Flag

Posted by Eric Covener <co...@gmail.com>.
On Wed, Apr 14, 2010 at 6:32 AM,  <ac...@softreset.de> wrote:
> On Wed, 14 Apr 2010 05:44:26 -0400, Eric Covener <co...@gmail.com> wrote:
>>> RewriteRule ^(.*)$ http://localhost:9090/index.jsp [P]
>>
>>> The browser ends up with a not working URL:
>>> http://localhost:9090/setup/login.jsp
>>
>> http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse
>
> I did not mention in this case it is about a full managed
> Linux box. Access to the Apache config is not permitted.
> One hat to use a .htaccess file.
>
> Is there something similar to ProxyPassReverse which works
> in the .htaccess?

Maybe 'Header edit Location ...' but I'm not sure if Header directives
in your htaccess will still be applicable after all the proxying work
is done (it wouldn't with ProxyPass, but it might since you had
mod_rewrite in htaccess)


-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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


Re: [users@httpd] RewriteRule with [P] Flag

Posted by ac...@softreset.de.
On Wed, 14 Apr 2010 05:44:26 -0400, Eric Covener <co...@gmail.com> wrote:
>> RewriteRule ^(.*)$ http://localhost:9090/index.jsp [P]
> 
>> The browser ends up with a not working URL:
>> http://localhost:9090/setup/login.jsp
> 
> http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse

I did not mention in this case it is about a full managed
Linux box. Access to the Apache config is not permitted.
One hat to use a .htaccess file.

Is there something similar to ProxyPassReverse which works
in the .htaccess?


Thx, Axel


---------------------------------------------------------------------
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


Re: [users@httpd] RewriteRule with [P] Flag

Posted by Eric Covener <co...@gmail.com>.
> RewriteRule ^(.*)$ http://localhost:9090/index.jsp [P]

> The browser ends up with a not working URL:
> http://localhost:9090/setup/login.jsp

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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