users@grizzly.java.net

Re: How to redirect HTTP to HTTPS

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Fri, 24 Jan 2014 22:35:44 -0800

Hi Joe,

IMO the easiest way to solve this is to register HttpHandler on port 80
and make it return HTTP response with status 301, and Location header
redirecting the client to port 443.

new HttpHandler() {

             @Override
             public void service(Request request, Response response)
throws Exception {
response.setStatus(HttpStatus.MOVED_PERMANENTLY_301);
                 response.setHeader(Header.Location, "https://...");
             }
}

Hope that helps.

WBR,
Alexey.

On 24.01.14 21:24, Joe Lin wrote:
> Hi,
>
> I'm running Grizzily 2.3.7. My question is how can I redirect all
> normal HTTP at 80 traffic to HTTPS at 443?
>
> Thanks.
> Joe