You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Herb Burnswell <he...@gmail.com> on 2018/06/07 19:36:21 UTC

[users@httpd] mod_proxy_http rewrite problem

All,

I'm facing what seemingly is a very difficult challenge, tyring to set up a
proxy to a backend application.  I say 'seemingly very difficult' because I
have reached out to the HTTPD community, codementor.io (offering money for
help), as well as consultants who say they really are not skilled enough to
help.  When I started looking into this (I've had to put it on the back
burner due to more urgent needs) I didn't anticipate the setup being
excessively difficult, but it seems to be.  My original message to the
group was:

http://mail-archives.apache.org/mod_mbox/httpd-users/201802.mbox/%3CCAOuzmw778mmRssv-%3DpLNB86xSReUnqqfzpY-%3D0LtgrxQyR28%2BA%40mail.gmail.com%3E

I did receive valuable guidance and appreciate the help.  My ultimate goal
is to get the proxy set up using mod_jk and I posted this message to the
group:

http://mail-archives.apache.org/mod_mbox/httpd-users/201803.mbox/%3CCAOuzmw5DRVon_sEkUbV%2BAHDTYHrRj%3D%2By9EHOeNWdEb%2BXPN3p%3Dw%40mail.gmail.com%3E

At this point I just want to get the proxy working using mod_proxy_http.
I've had some success in that I can get the vanity URL to serve the
application login page securely, but I'm having trouble with the back and
forth between the proxy and the application.  Here is the virtual host
configuration I am using:

<VirtualHost *:443>

        ServerName vanity.example.com
        ServerAlias www.vanity.example.com

        SSLEngine on
        SSLProxyEngine  on
        SSLProtocol all -SSLv2 -SSLv3
        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA
        SSLCertificateFile /etc/pki/tls/certs/my_bundle.crt

        <Proxy balancer://applicationcluster>

                BalancerMember https://app1.example.com:8443/frontpage
route=node1
                BalancerMember https://app2.example.com:8443/frontpage
route=node2
                BalancerMember https://app3.example.com:8443/frontpage
route=node3
                ProxySet lbmethod=bybusyness

        </Proxy>

        ProxyPreserveHost       On
        ProxyPass / balancer://applicationcluster/ stickysession=JSESSIONID
        ProxyPassReverse / balancer://applicationcluster/
stickysession=JSESSIONID

        RewriteEngine   On
        RewriteRule "^/frontpage(.+)" "$1" [R,L]

</VirtualHost>

This configuration allows for the frontpage to serve properly, however
trying to log in fails as the rewrite rule again strips the '/frontpage'
off of the requested path but it is needed for logic on the application
side:

[Thu Jun 07 11:22:41.711001 2018] [rewrite:trace2] [pid 101871:tid
140147827910400] mod_rewrite.c(470): [client 10.24.3.10:64324] 10.24.3.10 -
- [vanity.example.com/sid#55fa483335d8][rid#7f76a401a100/initial] rewrite
'/frontpage/zkau' -> '/zkau', referer: https://vanity.example.com/login.zul

I'm not even sure why the rewrite rule initially allows for the log in page
to serve, but if I don't have it in place the request goes into a loop.  I
don't want to make any changes on the application side, only on the proxy.

Is there a good way to handle this?  A rewite condition?

I appreciate any guidance.

Thanks in advance,

HB

Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Herb Burnswell <he...@gmail.com>.
>  Or if you want to masquerade /frontpage completetly, you could use
>   mod_proxy_html to rewrite response URLs on the fly.

Anybody have suggestions on how to masquerade /frontpage to rewrite
responses?

On Fri, Jun 15, 2018 at 12:33 PM, Herb Burnswell <
herbert.burnswell@gmail.com> wrote:

> >  What if you remove the ProxyPassReverse, leaving the 2 ProxyPass only?
>
> Thanks Yann.
>
> Unfortunately no, without the ProxyPassReverse directive the behavior is
> the same, it just loops.  The 302's are in the access log over and over:
>
>  10.24.3.10 - - [15/Jun/2018:12:16:40 -0700] "GET /frontpage/login.zul
> HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
> Gecko/20100101 Firefox/43.0" "305C0B70515B838AE70AC0F7DBA79799.node3"
>
>
>
>
> On Thu, Jun 14, 2018 at 11:34 PM, Yann Ylavic <yl...@gmail.com>
> wrote:
>
>> On Fri, Jun 15, 2018 at 12:34 AM, Herb Burnswell
>> <he...@gmail.com> wrote:
>> >
>> >> If you accept that /frontpage path going up to the client/browser once
>> >> the first / works, then you can:
>> >>    ProxyPass / balancer://applicationcluster/frontpage/ ...
>> >>    ProxyPass /frontpage/ balancer://applicationcluster/frontpage/ ...
>> >>    ProxyPassReverse / balancer://applicationcluster/frontpage/
>> >> The two ProxyPass handle the two kind of paths to forward (the
>> >> longuest match should be elected first).
>> >
>> > Using the two ProxyPass directives per above sends a request into a
>> loop.
>>
>> What if you remove the ProxyPassReverse, leaving the 2 ProxyPass only?
>>
>> Regards,
>> Yann.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>

Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Herb Burnswell <he...@gmail.com>.
It works !!!!

It works with the ProxyPassReverse included.

Yann - Thank you very much for all of your help, it's greatly appreciated..

Best,

HB

On Wed, Jun 20, 2018 at 7:54 AM, Yann Ylavic <yl...@gmail.com> wrote:

> On Tue, Jun 19, 2018 at 11:26 PM, Herb Burnswell
> <he...@gmail.com> wrote:
> >
> > Attached is the error_log (scrubbed, may be some replace oddities, but
> you
> > can see the progression..).
>
> OK, it seems that the ProxyPass(es) order matters actually.
>
> How about:
>     ProxyPass /frontpage/ balancer://applicationcluster/frontpage/ ...
>     ProxyPassReverse /frontpage/ balancer://applicationcluster/frontpage/
>     ProxyPass / balancer://applicationcluster/frontpage/ ...
> ?
>
> (that's without the /frontpage in the BalancerMembers)
> (the ProxyPassReverse may not be necessary with ProxyPreserveHost on)
>
>
> Regards,
> Yann.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Yann Ylavic <yl...@gmail.com>.
On Tue, Jun 19, 2018 at 11:26 PM, Herb Burnswell
<he...@gmail.com> wrote:
>
> Attached is the error_log (scrubbed, may be some replace oddities, but you
> can see the progression..).

OK, it seems that the ProxyPass(es) order matters actually.

How about:
    ProxyPass /frontpage/ balancer://applicationcluster/frontpage/ ...
    ProxyPassReverse /frontpage/ balancer://applicationcluster/frontpage/
    ProxyPass / balancer://applicationcluster/frontpage/ ...
?

(that's without the /frontpage in the BalancerMembers)
(the ProxyPassReverse may not be necessary with ProxyPreserveHost on)


Regards,
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Herb Burnswell <he...@gmail.com>.
Thank Yann.

Attached is the error_log (scrubbed, may be some replace oddities, but you
can see the progression..).

On Mon, Jun 18, 2018 at 10:41 PM, Yann Ylavic <yl...@gmail.com> wrote:

> On Fri, Jun 15, 2018 at 9:33 PM, Herb Burnswell
> <he...@gmail.com> wrote:
> >>  What if you remove the ProxyPassReverse, leaving the 2 ProxyPass only?
> >
> > Unfortunately no, without the ProxyPassReverse directive the behavior is
> the
> > same, it just loops.  The 302's are in the access log over and over:
> >
> >  10.24.3.10 - - [15/Jun/2018:12:16:40 -0700] "GET /frontpage/login.zul
> > HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
> > Gecko/20100101 Firefox/43.0" "305C0B70515B838AE70AC0F7DBA79799.node3"
>
> There is no loop in the configuration with ProxyPass(es) only, looks
> like this infinite redirection is generated on the backend.
> Could you please attach the error log (LogLevel trace7) of the loop?
>
> Regards,
> Yann.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Yann Ylavic <yl...@gmail.com>.
On Fri, Jun 15, 2018 at 9:33 PM, Herb Burnswell
<he...@gmail.com> wrote:
>>  What if you remove the ProxyPassReverse, leaving the 2 ProxyPass only?
>
> Unfortunately no, without the ProxyPassReverse directive the behavior is the
> same, it just loops.  The 302's are in the access log over and over:
>
>  10.24.3.10 - - [15/Jun/2018:12:16:40 -0700] "GET /frontpage/login.zul
> HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
> Gecko/20100101 Firefox/43.0" "305C0B70515B838AE70AC0F7DBA79799.node3"

There is no loop in the configuration with ProxyPass(es) only, looks
like this infinite redirection is generated on the backend.
Could you please attach the error log (LogLevel trace7) of the loop?

Regards,
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Herb Burnswell <he...@gmail.com>.
>  What if you remove the ProxyPassReverse, leaving the 2 ProxyPass only?

Thanks Yann.

Unfortunately no, without the ProxyPassReverse directive the behavior is
the same, it just loops.  The 302's are in the access log over and over:

 10.24.3.10 - - [15/Jun/2018:12:16:40 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "305C0B70515B838AE70AC0F7DBA79799.node3"




On Thu, Jun 14, 2018 at 11:34 PM, Yann Ylavic <yl...@gmail.com> wrote:

> On Fri, Jun 15, 2018 at 12:34 AM, Herb Burnswell
> <he...@gmail.com> wrote:
> >
> >> If you accept that /frontpage path going up to the client/browser once
> >> the first / works, then you can:
> >>    ProxyPass / balancer://applicationcluster/frontpage/ ...
> >>    ProxyPass /frontpage/ balancer://applicationcluster/frontpage/ ...
> >>    ProxyPassReverse / balancer://applicationcluster/frontpage/
> >> The two ProxyPass handle the two kind of paths to forward (the
> >> longuest match should be elected first).
> >
> > Using the two ProxyPass directives per above sends a request into a loop.
>
> What if you remove the ProxyPassReverse, leaving the 2 ProxyPass only?
>
> Regards,
> Yann.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Yann Ylavic <yl...@gmail.com>.
On Fri, Jun 15, 2018 at 12:34 AM, Herb Burnswell
<he...@gmail.com> wrote:
>
>> If you accept that /frontpage path going up to the client/browser once
>> the first / works, then you can:
>>    ProxyPass / balancer://applicationcluster/frontpage/ ...
>>    ProxyPass /frontpage/ balancer://applicationcluster/frontpage/ ...
>>    ProxyPassReverse / balancer://applicationcluster/frontpage/
>> The two ProxyPass handle the two kind of paths to forward (the
>> longuest match should be elected first).
>
> Using the two ProxyPass directives per above sends a request into a loop.

What if you remove the ProxyPassReverse, leaving the 2 ProxyPass only?

Regards,
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Herb Burnswell <he...@gmail.com>.
Thanks.

> If you accept that /frontpage path going up to the client/browser once
> the first / works, then you can:
>    ProxyPass / balancer://applicationcluster/frontpage/ ...
>    ProxyPass /frontpage/ balancer://applicationcluster/frontpage/ ...
>    ProxyPassReverse / balancer://applicationcluster/frontpage/
> The two ProxyPass handle the two kind of paths to forward (the
> longuest match should be elected first).

Using the two ProxyPass directives per above sends a request into a loop.

access_log:

10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "F65A3883E2839AD76E9E0BFAA3E44F45.node3"
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 -
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "F65A3883E2839AD76E9E0BFAA3E44F45.node3"
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 -
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "F65A3883E2839AD76E9E0BFAA3E44F45.node3"
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 -
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "F65A3883E2839AD76E9E0BFAA3E44F45.node3"
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 -
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "F65A3883E2839AD76E9E0BFAA3E44F45.node3"
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 -
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "F65A3883E2839AD76E9E0BFAA3E44F45.node3"
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 -
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "F65A3883E2839AD76E9E0BFAA3E44F45.node3"
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 -
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "F65A3883E2839AD76E9E0BFAA3E44F45.node3"
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 -
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "F65A3883E2839AD76E9E0BFAA3E44F45.node3"
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 -
10.24.3.10 - - [14/Jun/2018:15:31:30 -0700] "GET /frontpage/login.zul
HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0)
Gecko/20100101 Firefox/43.0" "F65A3883E2839AD76E9E0BFAA3E44F45.node3"


That includes removing the /frontpage from the BalancerMember declarations:

<Proxy balancer://applicationcluster>

                BalancerMember https://app1.example.com:8443
<https://app1.example.com:8443/frontpage> route=node1
                BalancerMember https://app2.example.com:8443
<https://app2.example.com:8443/frontpage> route=node2
                BalancerMember https://app3.example.com:8443
<https://app3.example.com:8443/frontpage> route=node3
                ProxySet lbmethod=bybusyness

</Proxy>

ProxyPreserveHost       On
ProxyPass / balancer://applicationcluster/frontpage/
stickysession=JSESSIONID
ProxyPass /frontpage/ balancer://applicationcluster/frontpage/
stickysession=JSESSIONID
ProxyPassReverse / balancer://applicationcluster/frontpage/
stickysession=JSESSIONID



> Or if you want to masquerade /frontpage completetly, you could use
> mod_proxy_html to rewrite response URLs on the fly.
>
> The first option is probably simpler and it fits your needs, does it work?
>
>
Well, so far the only option that has been partially successful for me is
to use a rewrite.  As mentioned, If I use:

RewriteEngine   On
RewriteRule "^/frontpage(.+)" "$1" [R,L]

^^^^
This allows for the login page to load successfully but subsequent requests
fail.

Any thoughts on a URL rewrite(s) that might work?  I've played around with
%{REQUEST_URI} and IS_SUBREQ but have had not success so far..

Any suggestions are very welcome..

Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Yann Ylavic <yl...@gmail.com>.
On Thu, Jun 14, 2018 at 9:16 PM, Herb Burnswell
<he...@gmail.com> wrote:
> Community,
>
> Is this issue that I'm struggling with really that large of a challenge?  If
> it is, that's fine, I'm trying to judge if it's something that I should
> abandon or if it can be done at all..

Not that much challenging I think, as I understand it the backend
(frontage) sends links in HTML with /frontpage prefix, so that's what
comes back.

You have multiple options here, possibly.
If you accept that /frontpage path going up to the client/browser once
the first / works, then you can:
    ProxyPass / balancer://applicationcluster/frontpage/ ...
    ProxyPass /frontpage/ balancer://applicationcluster/frontpage/ ...
    ProxyPassReverse / balancer://applicationcluster/frontpage/
The two ProxyPass handle the two kind of paths to forward (the
longuest match should be elected first).

Or if you want to masquerade /frontpage completetly, you could use
mod_proxy_html to rewrite response URLs on the fly.

The first option is probably simpler and it fits your needs, does it work?

Regards,
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Herb Burnswell <he...@gmail.com>.
 Community,

Is this issue that I'm struggling with really that large of a challenge?
If it is, that's fine, I'm trying to judge if it's something that I should
abandon or if it can be done at all..

Thanks,

HB

On Sun, Jun 10, 2018 at 9:23 PM, Herb Burnswell <herbert.burnswell@gmail.com
> wrote:

> Thanks again Yann.
>
> >  I'm not sure to understand, you want the request to be without
> > "/frontpage" suffix between the browsers and the proxy (i.e.
> > https://vanity.example.com) and with the suffix added between proxy
> > and the backend (i.e. https://vanity.example.com/frontpage), right?
>
> You are correct, this is exactly the behavior I'm looking to configure,
> the backend application needs the /frontpage path but we don't want users
> to need to add it.  However, I wish I could say I'm making progress but I'm
> really not other than I have a better understanding of why it's failing.
>
> It does not matter if I append the /frontpage path to the end of the
> ProxyPath directive or the BalancerMember declarations.  Here is what
> happens:
>
> Without any Rewrite directive, the request is directed to the backend per
> the ProxyPath declaration as:
>
>  https://app(1|2|3).example.com:8443/frontpage
> <https://app1.example.com:8443/frontpage> using https://vanity.example.com
>
> The backend then sends a request for 'GET /frontpage/login.jsp' using the
> vanity URL and it again hits the proxy.  However, the proxy just goes back
> through the same direction and again appends the request using ProxyPass.
> It ends up looking like:
>
> https://vanity.example.com/frontpage/frontpage/login.jsp instead of the
> desired https://vanity.example.com/frontpage/login.jsp
>
> So, using the rewrite rule:
>
> RewriteRule "^/frontpage(.+)" "$1" [R,L]
>
> The initial page load works fine (it ends up being:
> https://vanity.example.com/login.jsp).  But any subsequent requests fail
> as they all begin with '/frontpage' as in:
>
> GET /frontpage/path/to/file
>
> And the rewrite rule again strips the '/frontpage' from the GET request
> and causes it to fail.
>
> I have to imagine there is a rewrite condition or conditions that will
> allow for the desired behavior to work but I'm just not experienced enough
> yet.
>
> I hope I have not completely confused the situation, any guidance is
> greatly appreciated as always..
>
> HB
>
>
>
> On Sun, Jun 10, 2018 at 12:31 PM, Yann Ylavic <yl...@gmail.com>
> wrote:
>
>> Hi HB,
>>
>> On Sun, Jun 10, 2018 at 5:05 PM, Herb Burnswell
>> <he...@gmail.com> wrote:
>> >
>> > I need the proxy to work as: https://vanity.example.com
>> >
>> > I'm thinking this may require use of  RewriteCond directives, however I
>> may
>> > be going about this wrong.
>> >
>> > Is there a way to define an 'active' request to avoid looping through
>> the
>> > same ProxyPass or ProxyPassMatch needed for an initial request?
>>
>> I'm not sure to understand, you want the request to be without
>> "/frontpage" suffix between the browsers and the proxy (i.e.
>> https://vanity.example.com) and with the suffix added between proxy
>> and the backend (i.e. https://vanity.example.com/frontpage), right?
>>
>> If this is the case, maybe something like this then (the opposite
>> rewrite of what I've told you so far :p ):
>>     ProxyPass / balancer://applicationcluster/frontpage/ ...
>>     ProxyPassReverse / balancer://applicationcluster/frontpage/
>> You would then remove the "/frontpage" suffix from the BalancerMember
>> declarations.
>>
>> Since ProxyPass would do the rewrite from "/" => "/frontpage/", you
>> don't need mod_rewrite here.
>> There is no case where "/frontpage" (without the trailing '/') can
>> arrive on the backend side since ProxyPass will always start the
>> forwarded path with "/frontpage/", but I suppose "/frontpage" and
>> "/frontpage/" work equally on the backend no?
>>
>> Hope that helps..
>>
>> Regards,
>> Yann.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>

Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Herb Burnswell <he...@gmail.com>.
Thanks again Yann.

>  I'm not sure to understand, you want the request to be without
> "/frontpage" suffix between the browsers and the proxy (i.e.
> https://vanity.example.com) and with the suffix added between proxy
> and the backend (i.e. https://vanity.example.com/frontpage), right?

You are correct, this is exactly the behavior I'm looking to configure, the
backend application needs the /frontpage path but we don't want users to
need to add it.  However, I wish I could say I'm making progress but I'm
really not other than I have a better understanding of why it's failing.

It does not matter if I append the /frontpage path to the end of the
ProxyPath directive or the BalancerMember declarations.  Here is what
happens:

Without any Rewrite directive, the request is directed to the backend per
the ProxyPath declaration as:

 https://app(1|2|3).example.com:8443/frontpage
<https://app1.example.com:8443/frontpage> using https://vanity.example.com

The backend then sends a request for 'GET /frontpage/login.jsp' using the
vanity URL and it again hits the proxy.  However, the proxy just goes back
through the same direction and again appends the request using ProxyPass.
It ends up looking like:

https://vanity.example.com/frontpage/frontpage/login.jsp instead of the
desired https://vanity.example.com/frontpage/login.jsp

So, using the rewrite rule:

RewriteRule "^/frontpage(.+)" "$1" [R,L]

The initial page load works fine (it ends up being:
https://vanity.example.com/login.jsp).  But any subsequent requests fail as
they all begin with '/frontpage' as in:

GET /frontpage/path/to/file

And the rewrite rule again strips the '/frontpage' from the GET request and
causes it to fail.

I have to imagine there is a rewrite condition or conditions that will
allow for the desired behavior to work but I'm just not experienced enough
yet.

I hope I have not completely confused the situation, any guidance is
greatly appreciated as always..

HB



On Sun, Jun 10, 2018 at 12:31 PM, Yann Ylavic <yl...@gmail.com> wrote:

> Hi HB,
>
> On Sun, Jun 10, 2018 at 5:05 PM, Herb Burnswell
> <he...@gmail.com> wrote:
> >
> > I need the proxy to work as: https://vanity.example.com
> >
> > I'm thinking this may require use of  RewriteCond directives, however I
> may
> > be going about this wrong.
> >
> > Is there a way to define an 'active' request to avoid looping through the
> > same ProxyPass or ProxyPassMatch needed for an initial request?
>
> I'm not sure to understand, you want the request to be without
> "/frontpage" suffix between the browsers and the proxy (i.e.
> https://vanity.example.com) and with the suffix added between proxy
> and the backend (i.e. https://vanity.example.com/frontpage), right?
>
> If this is the case, maybe something like this then (the opposite
> rewrite of what I've told you so far :p ):
>     ProxyPass / balancer://applicationcluster/frontpage/ ...
>     ProxyPassReverse / balancer://applicationcluster/frontpage/
> You would then remove the "/frontpage" suffix from the BalancerMember
> declarations.
>
> Since ProxyPass would do the rewrite from "/" => "/frontpage/", you
> don't need mod_rewrite here.
> There is no case where "/frontpage" (without the trailing '/') can
> arrive on the backend side since ProxyPass will always start the
> forwarded path with "/frontpage/", but I suppose "/frontpage" and
> "/frontpage/" work equally on the backend no?
>
> Hope that helps..
>
> Regards,
> Yann.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Yann Ylavic <yl...@gmail.com>.
Hi HB,

On Sun, Jun 10, 2018 at 5:05 PM, Herb Burnswell
<he...@gmail.com> wrote:
>
> I need the proxy to work as: https://vanity.example.com
>
> I'm thinking this may require use of  RewriteCond directives, however I may
> be going about this wrong.
>
> Is there a way to define an 'active' request to avoid looping through the
> same ProxyPass or ProxyPassMatch needed for an initial request?

I'm not sure to understand, you want the request to be without
"/frontpage" suffix between the browsers and the proxy (i.e.
https://vanity.example.com) and with the suffix added between proxy
and the backend (i.e. https://vanity.example.com/frontpage), right?

If this is the case, maybe something like this then (the opposite
rewrite of what I've told you so far :p ):
    ProxyPass / balancer://applicationcluster/frontpage/ ...
    ProxyPassReverse / balancer://applicationcluster/frontpage/
You would then remove the "/frontpage" suffix from the BalancerMember
declarations.

Since ProxyPass would do the rewrite from "/" => "/frontpage/", you
don't need mod_rewrite here.
There is no case where "/frontpage" (without the trailing '/') can
arrive on the backend side since ProxyPass will always start the
forwarded path with "/frontpage/", but I suppose "/frontpage" and
"/frontpage/" work equally on the backend no?

Hope that helps..

Regards,
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Herb Burnswell <he...@gmail.com>.
Hi,

Thank you for the response.

I need the proxy to work as: https://vanity.example.com

I'm thinking this may require use of  RewriteCond directives, however I may
be going about this wrong.

Is there a way to define an 'active' request to avoid looping through the
same ProxyPass or ProxyPassMatch needed for an initial request?

Thanks,

HB

On Sat, Jun 9, 2018 at 1:24 AM, Yann Ylavic <yl...@gmail.com> wrote:

> Hi,
>
> On Fri, Jun 8, 2018 at 9:07 PM, Herb Burnswell
> <he...@gmail.com> wrote:
> >
> > That being said I did test with modifying the ProxyPass and
> ProxyPassReverse
> > as you suggested, and it does work if an ending forward slash is added to
> > the end of the URL:
> >
> > https://vanity.example.com/frontpage/
> >
> > Given that bit of information, is there a way to get it to work without
> > needing to add the '/frontpage/' path to the URL?
>
> Possibly:
>     ProxyPass /frontpage balancer://applicationcluster ...
> or:
>     ProxyPassMatch ^/frontpage(/.*)?$ balancer://applicationcluster$1 ...
> ?
>
> With:
>     ProxyPassReverse /frontpage balancer://applicationcluster
> this time.
>
> Regards,
> Yann.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Yann Ylavic <yl...@gmail.com>.
Hi,

On Fri, Jun 8, 2018 at 9:07 PM, Herb Burnswell
<he...@gmail.com> wrote:
>
> That being said I did test with modifying the ProxyPass and ProxyPassReverse
> as you suggested, and it does work if an ending forward slash is added to
> the end of the URL:
>
> https://vanity.example.com/frontpage/
>
> Given that bit of information, is there a way to get it to work without
> needing to add the '/frontpage/' path to the URL?

Possibly:
    ProxyPass /frontpage balancer://applicationcluster ...
or:
    ProxyPassMatch ^/frontpage(/.*)?$ balancer://applicationcluster$1 ...
?

With:
    ProxyPassReverse /frontpage balancer://applicationcluster
this time.

Regards,
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Herb Burnswell <he...@gmail.com>.
Yann,

Thank you for the response.

I should have added to my post that we need the proxy to work without
requiring adding a path to the vanity URL as:

https://vanity.example.com/frontpage

That being said I did test with modifying the ProxyPass and
ProxyPassReverse as you suggested, and it does work if an ending forward
slash is added to the end of the URL:

https://vanity.example.com/frontpage/

Given that bit of information, is there a way to get it to work without
needing to add the '/frontpage/' path to the URL?

Any guidance is greatly appreciated..

HB

On Fri, Jun 8, 2018 at 12:04 AM, Yann Ylavic <yl...@gmail.com> wrote:

> Hello,
>
> On Thu, Jun 7, 2018 at 9:36 PM, Herb Burnswell
> <he...@gmail.com> wrote:
> >
> >         RewriteEngine   On
> >         RewriteRule "^/frontpage(.+)" "$1" [R,L]
>
> What about this instead of the above:
>         ProxyPass /frontpage/ balancer://applicationcluster/
> stickysession=JSESSIONID
>         ProxyPassReverse /frontpage/ balancer://applicationcluster/
> stickysession=JSESSIONID
> ?
>
> Regards,
> Yann.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] mod_proxy_http rewrite problem

Posted by Yann Ylavic <yl...@gmail.com>.
Hello,

On Thu, Jun 7, 2018 at 9:36 PM, Herb Burnswell
<he...@gmail.com> wrote:
>
>         RewriteEngine   On
>         RewriteRule "^/frontpage(.+)" "$1" [R,L]

What about this instead of the above:
        ProxyPass /frontpage/ balancer://applicationcluster/
stickysession=JSESSIONID
        ProxyPassReverse /frontpage/ balancer://applicationcluster/
stickysession=JSESSIONID
?

Regards,
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org