Skip to content

Commit

Permalink
Issue #1771 - add module for secure redirect
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed May 12, 2022
1 parent b47d9c4 commit b91182f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
22 changes: 22 additions & 0 deletions jetty-server/src/main/config/etc/jetty-secure-redirect.xml
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Get id="Handler" name="handler"/>
<Call name="setHandler">
<Arg>
<New class="org.eclipse.jetty.server.handler.HandlerList">
<Call name="addHandler">
<Arg>
<New id="SecuredRedirectHandler" class="org.eclipse.jetty.server.handler.SecuredRedirectHandler">
<Arg type="int"><Property name="jetty.redirect.code" default="302"/></Arg>
</New>
</Arg>
</Call>
<Call name="addHandler">
<Arg><Ref refid="Handler"/></Arg>
</Call>
</New>
</Arg>
</Call>
</Configure>
2 changes: 1 addition & 1 deletion jetty-server/src/main/config/etc/jetty.xml
Expand Up @@ -60,7 +60,7 @@
<!-- =========================================================== -->
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Set name="secureScheme" property="jetty.httpConfig.secureScheme"/>
<Set name="securePort" property="jetty.httpConfig.securePort"/>
<Set name="securePort"><Property name="jetty.httpConfig.securePort" default="8443"/></Set>
<Set name="outputBufferSize" property="jetty.httpConfig.outputBufferSize"/>
<Set name="outputAggregationSize" property="jetty.httpConfig.outputAggregationSize"/>
<Set name="requestHeaderSize" property="jetty.httpConfig.requestHeaderSize"/>
Expand Down
17 changes: 17 additions & 0 deletions jetty-server/src/main/config/modules/secure-redirect.mod
@@ -0,0 +1,17 @@
DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html

[description]
Enable SecuredRedirectHandler to redirect all http requests to https.

[tags]
handler

[depend]
server

[xml]
etc/jetty-secure-redirect.xml

[ini-template]
## The redirect code to use in the response.
# jetty.redirect.code=302

0 comments on commit b91182f

Please sign in to comment.