users@grizzly.java.net

Re: How to redirect HTTP to HTTPS

From: Joe Lin <jlin_at_peaxy.net>
Date: Mon, 27 Jan 2014 17:24:46 -0800

Thanks for the reply

You mention to register a regular HttpHandler on port 80. According to
Grizzly API, it seems that we can only register a handler based on request
path?

Regards,
Joe


On Fri, Jan 24, 2014 at 10:35 PM, Oleksiy Stashok <
oleksiy.stashok_at_oracle.com> wrote:

> 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://..."<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
>
>
>