You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Timo Meinen <ti...@googlemail.com> on 2010/04/22 12:25:21 UTC
How to configure ProxyPassReverse for SSL redirect
Hi,
our configuration is a Apache 2.2 web server, acting as a reverse
proxy for Tomcat 6. This is the configuration:
ServerName it.localhost.de
ProxyPass / ajp://127.0.0.1:8009/spike/
ProxyPassReverse / ajp://127.0.0.1:8009/spike/
ProxyPassReverseCookiePath /spike /
As you can see, the webapp is hosted under ContextPath /spike but
available through the proxy via /. Everything works fine, until the
webapp sends an redirect to HTTPS. This is done via SpringSecurity.
The problem is, that the ProxyPassReverse directive doesn't catch the
ContextPath and converts it, if it includes the complete address.
These are the logs from the web browser:
GET http://it.localhost.de/users/65 => 302 =>
https://it.localhost.de/spike/users/65
1) Why does the ProxyPassReverse doesn't convert the /spike back to /
in https://it.localhost.de/spike/users/65? Is it because the Header
isn't relative? The protocol is still AJP and so the Proxy should know
how to convert it, right?
1a) If so, how could the webapp switch from http to https and vice
versa, when not able to send the absolute address with a new protocol?
After this, I tried to set additional ProxyPassReverse directives:
ProxyPassReverse / https://it.localhost.de/spike/
ProxyPassReverse / http://it.localhost.de/spike/
This time, the /spike/ is converted to /, but the two directives leads
to an infintive loop of redirects to
http://it.localhost.de/<REQUEST-URI>.
2) How can I stop this loop? or better
3) How can I configure the ProxyPassReverse correctly?
As a workaround I have a RewriteRule added like this one
RewriteRule ^/spike/(.*)$ /$1 [R=301,L]
but this doesn't feel correct and it leads to 3 GET-Requests and
redirects each time the webapps wants it user to switch the protocol.
Thank you very much
Timo Meinen
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How to configure ProxyPassReverse for SSL redirect
Posted by Timo Meinen <ti...@googlemail.com>.
Here are some debug information to this problem. The message is logged
just after the 302 redirect to the https. The Context-Path of the
application is /spike:
[Tue Apr 27 16:54:39 2010] [debug] mod_proxy_ajp.c(239): proxy:
APR_BUCKET_IS_EOS
[Tue Apr 27 16:54:39 2010] [debug] mod_proxy_ajp.c(244): proxy: data
to read (max 8186 at 4)
[Tue Apr 27 16:54:39 2010] [debug] mod_proxy_ajp.c(259): proxy: got 0
bytes of data
[Tue Apr 27 16:54:39 2010] [debug] ajp_header.c(652): ajp_read_header:
ajp_ilink_received 04
[Tue Apr 27 16:54:39 2010] [debug] ajp_header.c(662): ajp_parse_type: got 04
[Tue Apr 27 16:54:39 2010] [debug] ajp_header.c(491):
ajp_unmarshal_response: status = 302
[Tue Apr 27 16:54:39 2010] [debug] ajp_header.c(502):
ajp_unmarshal_response: Number of headers is = 2
[Tue Apr 27 16:54:39 2010] [debug] proxy_util.c(1071): ppr: real:
ajp://127.0.0.1:9091/spike/
[Tue Apr 27 16:54:39 2010] [debug] ajp_header.c(564):
ajp_unmarshal_response: Header[0] [Location] =
[https://it.localhost.de/spike/users/3]
[Tue Apr 27 16:54:39 2010] [debug] ajp_header.c(564):
ajp_unmarshal_response: Header[1] [Content-Length] = [0]
[Tue Apr 27 16:54:39 2010] [debug] ajp_header.c(652): ajp_read_header:
ajp_ilink_received 05
[Tue Apr 27 16:54:39 2010] [debug] ajp_header.c(662): ajp_parse_type: got 05
[Tue Apr 27 16:54:39 2010] [debug] mod_proxy_ajp.c(498): proxy: got
response from 127.0.0.1:9091 (127.0.0.1)
[Tue Apr 27 16:54:39 2010] [debug] proxy_util.c(2062): proxy: AJP: has
released connection for (127.0.0.1)
[Tue Apr 27 16:54:39 2010] [info] Initial (No.1) HTTPS request
received for child 9 (server it.localhost.de:80)
[Tue Apr 27 16:54:44 2010] [debug] mod_proxy_ajp.c(45): proxy: AJP:
canonicalising URL //127.0.0.1:9091/spike/spike/users/3
[Tue Apr 27 16:54:44 2010] [debug] proxy_util.c(1488): [client
85.183.135.210] proxy: ajp: found worker ajp://127.0.0.1:9091/spike/
for ajp://127.0.0.1:9091/spike/spike/users/3, referer:
http://it.localhost.de/
Problem is that the "ajp_unmarshal_response: Header[0] [Location] =
[https://it.localhost.de/spike/users/3]" doesn't remove the /spike in
the response, so that the next request will lead to the
doubled-context-path: ajp://127.0.0.1:9091/spike/spike/users/3.
Thank you,
Timo
2010/4/27 Timo Meinen <ti...@googlemail.com>:
> Is someone out there, who can explain me, what the problem is?
>
> Does the ProxyPassReverse only removes the ContextPath if the protocol
> (http/https) in the response is the same than in the request? Is it
> possible to configure the Proxy to ignore the protocol information?
>
> Thank you for any hint - I am stuck with this problem.
>
> Best regards,
> Timo
>
> 2010/4/22 Timo Meinen <ti...@googlemail.com>:
>> Hi Hassan,
>>
>> yes, there are two VirtualHost entries. One for port 80 and one for
>> port 443 with SSL engine enabled. Both have the same proxy
>> configuration.
>>
>> Timo
>>
>> 2010/4/22 Hassan Schroeder <ha...@gmail.com>:
>>> On Thu, Apr 22, 2010 at 3:25 AM, Timo Meinen <ti...@googlemail.com> wrote:
>>>
>>>> our configuration is a Apache 2.2 web server, acting as a reverse
>>>> proxy for Tomcat 6. This is the configuration:
>>>> ServerName it.localhost.de
>>>> ProxyPass / ajp://127.0.0.1:8009/spike/
>>>> ProxyPassReverse / ajp://127.0.0.1:8009/spike/
>>>> ProxyPassReverseCookiePath /spike /
>>>
>>> That's *one* configuration -- do you have this for both the standard
>>> port 80 and SSL port 443?
>>>
>>> In a default 2.2.x install there are separate extra/httpd-vhosts.conf and
>>> extra/httpd-ssl.conf files.
>>>
>>> --
>>> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>>> twitter: @hassan
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>>
>>
>> --
>> Glück Auf
>> Timo
>>
>
>
>
> --
> Glück Auf
> Timo
>
--
Glück Auf
Timo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How to configure ProxyPassReverse for SSL redirect
Posted by Timo Meinen <ti...@googlemail.com>.
Hi,
Nick Kew from the httpd-users list pointed me to the final solution:
The problem is, that the redirect is initiated through the Location
header, which can be rewrited with mod_headers:
Header edit Location ^([^/]*//[^/]*)?/spike/(.*)$ $1/$2
I think, mod_proxy should rewrite this header, too, like any other
header it rewrites. Is it a bug or am I missing something?
Timo
2010/4/28 Mark Thomas <ma...@apache.org>:
> On 27/04/2010 04:25, Timo Meinen wrote:
>>
>> Is someone out there, who can explain me, what the problem is?
>
> It looks like a bug in mod_proxy_ajp. Check you are using the latest httpd
> release (2.2.15) and if you still see the problem, open a bug. Note:
> mod_proxy_ajp is maintained by the httpd project.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How to configure ProxyPassReverse for SSL redirect
Posted by Mark Thomas <ma...@apache.org>.
On 27/04/2010 04:25, Timo Meinen wrote:
> Is someone out there, who can explain me, what the problem is?
It looks like a bug in mod_proxy_ajp. Check you are using the latest
httpd release (2.2.15) and if you still see the problem, open a bug.
Note: mod_proxy_ajp is maintained by the httpd project.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How to configure ProxyPassReverse for SSL redirect
Posted by Timo Meinen <ti...@googlemail.com>.
Is someone out there, who can explain me, what the problem is?
Does the ProxyPassReverse only removes the ContextPath if the protocol
(http/https) in the response is the same than in the request? Is it
possible to configure the Proxy to ignore the protocol information?
Thank you for any hint - I am stuck with this problem.
Best regards,
Timo
2010/4/22 Timo Meinen <ti...@googlemail.com>:
> Hi Hassan,
>
> yes, there are two VirtualHost entries. One for port 80 and one for
> port 443 with SSL engine enabled. Both have the same proxy
> configuration.
>
> Timo
>
> 2010/4/22 Hassan Schroeder <ha...@gmail.com>:
>> On Thu, Apr 22, 2010 at 3:25 AM, Timo Meinen <ti...@googlemail.com> wrote:
>>
>>> our configuration is a Apache 2.2 web server, acting as a reverse
>>> proxy for Tomcat 6. This is the configuration:
>>> ServerName it.localhost.de
>>> ProxyPass / ajp://127.0.0.1:8009/spike/
>>> ProxyPassReverse / ajp://127.0.0.1:8009/spike/
>>> ProxyPassReverseCookiePath /spike /
>>
>> That's *one* configuration -- do you have this for both the standard
>> port 80 and SSL port 443?
>>
>> In a default 2.2.x install there are separate extra/httpd-vhosts.conf and
>> extra/httpd-ssl.conf files.
>>
>> --
>> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>> twitter: @hassan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
>
> --
> Glück Auf
> Timo
>
--
Glück Auf
Timo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How to configure ProxyPassReverse for SSL redirect
Posted by Timo Meinen <ti...@googlemail.com>.
Hi Hassan,
yes, there are two VirtualHost entries. One for port 80 and one for
port 443 with SSL engine enabled. Both have the same proxy
configuration.
Timo
2010/4/22 Hassan Schroeder <ha...@gmail.com>:
> On Thu, Apr 22, 2010 at 3:25 AM, Timo Meinen <ti...@googlemail.com> wrote:
>
>> our configuration is a Apache 2.2 web server, acting as a reverse
>> proxy for Tomcat 6. This is the configuration:
>> ServerName it.localhost.de
>> ProxyPass / ajp://127.0.0.1:8009/spike/
>> ProxyPassReverse / ajp://127.0.0.1:8009/spike/
>> ProxyPassReverseCookiePath /spike /
>
> That's *one* configuration -- do you have this for both the standard
> port 80 and SSL port 443?
>
> In a default 2.2.x install there are separate extra/httpd-vhosts.conf and
> extra/httpd-ssl.conf files.
>
> --
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
> twitter: @hassan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
Glück Auf
Timo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How to configure ProxyPassReverse for SSL redirect
Posted by Hassan Schroeder <ha...@gmail.com>.
On Thu, Apr 22, 2010 at 3:25 AM, Timo Meinen <ti...@googlemail.com> wrote:
> our configuration is a Apache 2.2 web server, acting as a reverse
> proxy for Tomcat 6. This is the configuration:
> ServerName it.localhost.de
> ProxyPass / ajp://127.0.0.1:8009/spike/
> ProxyPassReverse / ajp://127.0.0.1:8009/spike/
> ProxyPassReverseCookiePath /spike /
That's *one* configuration -- do you have this for both the standard
port 80 and SSL port 443?
In a default 2.2.x install there are separate extra/httpd-vhosts.conf and
extra/httpd-ssl.conf files.
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org