I want to redirect all requests for http to https using Jetty (6.1.24). For some reason (my ignorance) this is eluding me. This is what I have:
<New id="redirect" class="org.mortbay.jetty.handler.rewrite.RedirectPatternRule">
<Set name="pattern">http://foobar.com/*</Set>
<Set name="location">https://foobar.com</Set>
</New>
In response I get 200 – ok, and the body is the page over http, ie the redirect doesn't occur.
Best Answer
Speaking for Jetty 9... Here's how you can do it provided that your SSL connector already works:
Step 1: Make sure everything goes through SSL by adding this to your web.xml. If you try to access a resource through HTTP, this will return a 403 !SECURE error
Step 2: Have Jetty redirect to HTTPS when it sees a 403 !SECURE error by adding this to your jetty.xml