java - Jetty: Redirect HTTP to HTTPS for static content -
i have set jetty 9.3 2 xml context configurations. 1 static content:
<?xml version="1.0" encoding="utf-8"?> <!doctype configure public "-//jetty//configure//en" "http://www.eclipse.org/jetty/configure_9_0.dtd"> <configure class="org.eclipse.jetty.server.handler.contexthandler"> <set name="contextpath">/static</set> <set name="handler"> <new class="org.eclipse.jetty.server.handler.resourcehandler"> <set name="resourcebase">/home/user/static</set> <set name="directorieslisted">true</set> </new> </set> </configure>
and 1 web application (war file):
<?xml version="1.0" encoding="utf-8"?> <!doctype configure public "-//jetty//configure//en" "http://www.eclipse.org/jetty/configure.dtd"> <configure class="org.eclipse.jetty.webapp.webappcontext"> <set name="contextpath">/webapp</set> <set name="war">/home/user/webapp.war</set> </configure>
i used this answer set jetty forward http requests https. more specifically, added following jetty/etc/webdefault.xml
:
<security-constraint> <web-resource-collection> <web-resource-name>everything</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>confidential</transport-guarantee> </user-data-constraint> </security-constraint>
and added following httpconfiguration
in jetty/etc/jetty.xml
:
<call name="addcustomizer"> <arg> <new class="org.eclipse.jetty.server.securerequestcustomizer" /> </arg> </call>
this works web application (i.e. accessing server through http @ '/webapp' redirect https), doesn't seem affect static content served under '/static'. assume because setting added webdefault.xml
applies web applications since have applicable web.xml
file.
how can set http requests redirect https pages served static content?
as far tell (e.g., based on this so , this sf , jetty docs) it's not configurable static content, webapps.
what could (that not mean should way) create custom @prematching
filter if using jax-rs or custom messagehandler
if using jax-ws redirection programatically (e.g., through returning http 301).
Comments
Post a Comment