[erlang-questions] Cowboy: is it possible to detect that request is http and redirect to https?

Loïc Hoguin <>
Thu Feb 27 17:05:30 CET 2014


Oh I see, I misunderstood the question.

I am guessing the connection stops in ssl:ssl_accept/1 which fails the 
handshake. I am not sure how you would handle something like this 
personally. Perhaps you can recv the first few bytes before ssl_accept, 
check them and unrecv if they aren't plain HTTP? But that would only 
(possibly) work if you have gen_tcp first and then upgrade that socket 
to SSL.

On 02/27/2014 05:00 PM, Max Lapshin wrote:
> No, it will not get called, because ranch is going to interpret incoming
> traffic as SSL, but it is plain HTTP.
>
>
>
> On Thu, Feb 27, 2014 at 7:57 PM, Loïc Hoguin <
> <mailto:>> wrote:
>
>     The very first argument to init/3 gives you something like {tcp,
>     http} or {ssl, http} or {ssl, spdy}, etc.
>
>
>     On 02/27/2014 04:56 PM, Max Lapshin wrote:
>
>
>         I've configured cowboy server to listen on port 443.
>
>         User is typing: http://server:443/  and see white screen.
>
>         Is it possible somehow to detect that it is plain http going to
>         ssl port
>         and redirect it to https?
>
>
>
>         _________________________________________________
>         erlang-questions mailing list
>          <mailto:>
>         http://erlang.org/mailman/__listinfo/erlang-questions
>         <http://erlang.org/mailman/listinfo/erlang-questions>
>
>
>     --
>     Loïc Hoguin
>     http://ninenines.eu
>
>

-- 
Loïc Hoguin
http://ninenines.eu



More information about the erlang-questions mailing list