Discussion:
renderFullUrl for apache internal redirected page
smallufo
2018-08-04 10:44:42 UTC
Permalink
My server is apache frontend , redirecting all port 80 to 443
and with '/app' prefix , proxyPass to internal tomcat , listening to port
8080

I use the following line to get full url
val absUrl =

requestCycle.urlRenderer.renderFullUrl(Url.parse(urlFor(MyPage::class.java,
pps).toString()))


The browser url shows https
but the absUrl is http

I trace the code , down to
UrlRenderer.resolveProtocol() and choose()

find my
request.getClientUrl().getPort() = 80

so it chooses http , not https

Any way to fix this ?

wicket-8.0.0
Bas Gooren
2018-08-04 11:11:56 UTC
Permalink
Hi!


This is because without additional configuration, your tomcat does not
“know”/see that the original request came in by https.


Wicket has support for automatically picking this up, see
https://ci.apache.org/projects/wicket/apidocs/org/apache/wicket/protocol/http/servlet/XForwardedRequestWrapperFactory.html

(property “protocolHeader).

You can install it with the following code in your Application’s init
method:


getFilterFactoryManager().add( new XForwardedRequestWrapperFactory() );


We have set the property “protocolHeader” to “X-Forwarded-Proto”, and set
this header in our apache vhost configuration:


Header set X-Forwarded-Proto “https”

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 4 augustus 2018 bij 12:44:59, smallufo (***@gmail.com) schreef:

My server is apache frontend , redirecting all port 80 to 443
and with '/app' prefix , proxyPass to internal tomcat , listening to port
8080

I use the following line to get full url
val absUrl =

requestCycle.urlRenderer.renderFullUrl(Url.parse(urlFor(MyPage::class.java,
pps).toString()))


The browser url shows https
but the absUrl is http

I trace the code , down to
UrlRenderer.resolveProtocol() and choose()

find my
request.getClientUrl().getPort() = 80

so it chooses http , not https

Any way to fix this ?

wicket-8.0.0

Loading...