Hi Martin,

The #sendRedirect sends a relative URL and them the servlet generates the
Location header with the original location with HTTP instead the
X-Forwarded-Proto scheme.
The balancer also sends a X-Host header, so I had to concatenate the host
and scheme to the URL before the #sendRedirect call.

Thanks.

On Mon, May 15, 2017 at 11:21 AM, Marcel Barbosa Pinto <
marcel.po...@gmail.com> wrote:

> Hi Martin,
>
> I've found something that could be related, at this line below, a new Url
> instance is created without being configured with the protocol. Is this URL
> relative or absolute?
>
> https://github.com/apache/wicket/blob/9e42a9548adb0da540e4e87d491f58
> 24e778537e/wicket-core/src/main/java/org/apache/wicket/
> core/request/mapper/PageInstanceMapper.java#L129
>
> I'll will try to debug the code later.
> Thanks.
>
>
>
>
> On Mon, May 15, 2017 at 3:56 AM, Martin Grigorov <mgrigo...@apache.org>
> wrote:
>
>> Hi,
>>
>> Put a breakpoint at org.apache.wicket.request.Url#getProtocol() and see
>> what it returns.
>> I guess the redirect is an absolute url and that's why it breaks.
>> See org.apache.wicket.protocol.http.servlet.ServletWebResponse#s
>> endRedirect
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>> https://twitter.com/mtgrigorov
>>
>> On Mon, May 15, 2017 at 5:01 AM, Marcel Barbosa Pinto <
>> marcel.po...@gmail.com> wrote:
>>
>> > Hi,
>> >
>> > I am using a balancer which sends the X-Forwarded-Proto header to my
>> Wicket
>> > application.
>> >
>> > I`ve added the following filters:
>> >
>> >  getFilterFactoryManager()
>> > >             .addSecuredRemoteAddressRequestWrapperFactory(null)
>> > >             .addXForwardedRequestWrapperFactory(null);
>> > >
>> >
>> > And the HttpsMapper:
>> >
>> > setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new
>> > > HttpsConfig())
>> > >
>> >
>> >
>> > And the following init-param into web.xml
>> >
>> > <init-param>
>> > >           <param-name>protocolHeader</param-name>
>> > >           <param-value>X-Forwarded-Proto</param-value>
>> > >  </init-param>
>> > >
>> >
>> >
>> > When I debug I can see that the header is working inside a
>> > RequestCycleListener
>> >
>> > HttpServletRequest req = (HttpServletRequest)
>> > > cycle.getRequest().getContainerRequest();
>> > > System.out.println("-->" + req.getScheme() + " ==" +
>> > > req.getHeader("X-Forwarded-Proto");
>> > >
>> >
>> >
>> > The problem occurs when some versioned page is created and wicket
>> redirect
>> > it to the same URL but with the HTTP:// instead, for example:
>> >
>> > *https://*www.wicket.com/statefullPage
>> > -> Response header: 302 (Location: *http://*www.wicket.com/
>> > statefullPage*?1*
>> > )
>> >
>> > If I change it back to HTTPS it works:
>> >
>> > *https://*www.wicket.com/statefullPage
>> > *?1*
>> > *-> *Response 200 OK
>> >
>> > I believe that in some redirection logic the original schema is being
>> lost
>> > somehow, during page versioning.
>> > This problem only occurs when using the "X-Forwarded-Proto" header
>> >
>> > Using Wicket 7.6.0
>> > Any suggestions?
>> >
>> > Thanks!
>> >
>>
>
>
>
> --
>
> Marcel Barbosa Pinto
> 55 11 98255 8288
>



-- 

Marcel Barbosa Pinto
55 11 98255 8288

Reply via email to