HTTP -> HTTPS redirect

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

HTTP -> HTTPS redirect

hshorter
Is there a way to redirect a browser from HTTP to HTTPS?

For example, I enter "localhost:1234/MyApplication" into a browser and I would like it to redirect to "https://localhost:1234/MyApplication".

Thanks.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3088137
Reply | Threaded
Open this post in threaded view
|

Re: HTTP -> HTTPS redirect

Fabian Mandelbaum
Quick idea, sorry if I don't put little/any code (it may not even work, trying won't hurt much hopefully...):

Have your whole app below a given URI 'base' path, say: yourapp/

Make the first resource in the routing chain a Filter that will take the Reference from the Request and a) change its protocol from http to https; b) prepend "yourapp/" on the path; c) redirect to the updated Reference, then set it up with something like this:

Router grouter = YourApp.getGuardedRouter();
grouter.attach("/", YourHttpsRedirector.class);
grouter.attach("/yourapp/route1/", YourAppCollectionResourceHandler1.class);
grouter.attach("/yourapp/route1/{element}", YourAppElementResourceHandler1.class);
...
...
grouter.attach("/yourapp/routeN/", YourAppCollectionResourceHandlerN.class);

Hope this helps.


On Tue, Sep 9, 2014 at 12:45 PM, hshorter <[hidden email]> wrote:
Is there a way to redirect a browser from HTTP to HTTPS?

For example, I enter "localhost:1234/MyApplication" into a browser and I would like it to redirect to "https://localhost:1234/MyApplication".

Thanks.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3088137



--
Fabián Mandelbaum
IS Engineer
Reply | Threaded
Open this post in threaded view
|

RE: Re: HTTP -> HTTPS redirect

hshorter
Thanks for the reply. Unfortunately I can't change the path of the application as there are previous versions we have to interop with. We also expose the same resources using HTTP on a different port, so we're just trying to redirect the protocol from HTTP -> HTTPS for the HTTPS port.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3088185
Reply | Threaded
Open this post in threaded view
|

Re: Re: HTTP -> HTTPS redirect

Fabian Mandelbaum
And I guess an external redirection/URI-rewriting with Apache is not possible either?

On Wed, Sep 10, 2014 at 7:20 AM, hshorter <[hidden email]> wrote:
Thanks for the reply. Unfortunately I can't change the path of the application as there are previous versions we have to interop with. We also expose the same resources using HTTP on a different port, so we're just trying to redirect the protocol from HTTP -> HTTPS for the HTTPS port.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3088185



--
Fabián Mandelbaum
IS Engineer
Reply | Threaded
Open this post in threaded view
|

RE: Re: Re: HTTP -> HTTPS redirect

hshorter
That's my next research area :) I'll have a chat with out subject expert and see if there is anything we can do external to Restlet.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3088214
Reply | Threaded
Open this post in threaded view
|

RE: Re: Re: HTTP -> HTTPS redirect

hshorter
In reply to this post by Fabian Mandelbaum
Looks like an Apache solution won't be possible.

Really we need Restlet to return a client redirect to send it to the correct place. I'm not sure if Restlet can do that?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3088224
Reply | Threaded
Open this post in threaded view
|

RE: Re: Re: HTTP -> HTTPS redirect

Primož Kokol
Hi Hshorter,

Did you (or anyone else) maybe found a solution for this? I am also trying to find a way to achieve exactly the same behaviour.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3091418
Reply | Threaded
Open this post in threaded view
|

RE: Re: Re: HTTP -> HTTPS redirect

Primož Kokol
FYI - I've posted the same question on SO:

http://stackoverflow.com/questions/26975059/restlet-http-to-https-non-default-port-redirect

but until now I haven't received any answer.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3091649