[Libwebsockets] How to redirect http to https? If it needs vhost on 80, how to create a vhost?

satya gowtham kudupudi satyagowtham.k at gmail.com
Wed Dec 7 15:46:04 CET 2016


I've created a context for each http and https on ports 80 and 443 respectively and I am servicing both the contexts in loop.
Everything is working great!!

However I got the below message
lwsts[28123]: lws_context_init_server_ssl: SSL_CTX_load_verify_locations unhappy
should I have to be unhappy about that? What does it mean?

Below is the complete log printed on the screen
lwsts[28123]: libwebsockets test server - license LGPL2.1+SLE
lwsts[28123]: (C) Copyright 2010-2016 Andy Green <andy at warmcat.com>
lwsts[28123]: Running in server mode
lwsts[28123]: Initial logging level 15
lwsts[28123]: Libwebsockets version: 2.1.0 ubuntu at ip-172-31-18-67-v2.0.0-196-g123b449
lwsts[28123]: IPV6 not compiled in
lwsts[28123]: libev support not compiled in
lwsts[28123]: libuv support not compiled in
lwsts[28123]:  LWS_DEF_HEADER_LEN    : 4096
lwsts[28123]:  LWS_MAX_PROTOCOLS     : 5
lwsts[28123]:  LWS_MAX_SMP           : 32
lwsts[28123]:  SPEC_LATEST_SUPPORTED : 13
lwsts[28123]:  sizeof (*info)        : 328
lwsts[28123]:  SYSTEM_RANDOM_FILEPATH: '/dev/urandom'
lwsts[28123]:  default timeout (secs): 5
lwsts[28123]:  Threads: 1 each 1024 fds
lwsts[28123]:  mem: context:          9280 bytes (5184 ctx + (1 thr x 4096))
lwsts[28123]:  mem: http hdr rsvd:   122880 bytes (1 thr x (4096 + 3584) x 16))
lwsts[28123]:  mem: pollfd map:       8192
lwsts[28123]:  mem: platform fd map:  8192 bytes
lwsts[28123]:  Compiled with OpenSSL support
lwsts[28123]: Creating Vhost 'www.ferryfair.com' port 80, 2 protocols, IPv6 off
lwsts[28123]:  Using non-SSL mode
lwsts[28123]:  SSL options 0x3520004
lwsts[28123]:  Listening on port 80
lwsts[28123]:  LWS_MAX_EXTENSIONS_ACTIVE: 2
lwsts[28123]:  mem: per-conn:          512 bytes + protocol rx buf
lwsts[28123]:  canonical_hostname = ip-172-31-18-67
lwsts[28123]: Initial logging level 15
lwsts[28123]: Libwebsockets version: 2.1.0 ubuntu at ip-172-31-18-67-v2.0.0-196-g123b449
lwsts[28123]: IPV6 not compiled in
lwsts[28123]: libev support not compiled in
lwsts[28123]: libuv support not compiled in
lwsts[28123]:  LWS_DEF_HEADER_LEN    : 4096
lwsts[28123]:  LWS_MAX_PROTOCOLS     : 5
lwsts[28123]:  LWS_MAX_SMP           : 32
lwsts[28123]:  SPEC_LATEST_SUPPORTED : 13
lwsts[28123]:  sizeof (*info)        : 328
lwsts[28123]:  SYSTEM_RANDOM_FILEPATH: '/dev/urandom'
lwsts[28123]:  default timeout (secs): 5
lwsts[28123]:  Threads: 1 each 1024 fds
lwsts[28123]:  mem: context:          9280 bytes (5184 ctx + (1 thr x 4096))
lwsts[28123]:  mem: http hdr rsvd:   122880 bytes (1 thr x (4096 + 3584) x 16))
lwsts[28123]:  mem: pollfd map:       8192
lwsts[28123]:  mem: platform fd map:  8192 bytes
lwsts[28123]:  Compiled with OpenSSL support
lwsts[28123]: Creating Vhost 'www.ferryfair.com' port 443, 2 protocols, IPv6 off
lwsts[28123]:  SSL ciphers: 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4:!HMAC_SHA1:!SHA1:!DHE-RSA-AES128-GCM-SHA256:!DHE-RSA-AES128-SHA256:!AES128-GCM-SHA25
lwsts[28123]:  Using SSL mode
lwsts[28123]: lws_context_init_server_ssl: SSL_CTX_load_verify_locations unhappy
lwsts[28123]:  SSL ECDH curve 'prime256v1'
lwsts[28123]:  SSL options 0x35A0004
lwsts[28123]:  Listening on port 443
lwsts[28123]:  LWS_MAX_EXTENSIONS_ACTIVE: 2
lwsts[28123]:  mem: per-conn:          512 bytes + protocol rx buf
lwsts[28123]:  canonical_hostname = ip-172-31-18-67
lwsts[28123]: lws_protocol_init
lwsts[28123]: lws_protocol_init

--
Gowtham

> On 06-Dec-2016, at 11:48 PM, satya gowtham kudupudi <satyagowtham.k at gmail.com> wrote:
> 
> What I have done is I have copied the info of actual host running on 443 and set the port to 80 and created a new context with the copied info.
> 
> info.vhost_name="www.ferryfair.com <http://www.ferryfair.com/>";
> lws_context_creation_info http_info = info;
> http_info.options &= ~LWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS;
> infohttp.port=80;
> lws_context* httpcontext = lws_create_context(&wss->infohttp);
> struct lws_vhost* pVHost=lws_create_vhost(wss->httpcontext,  wss->infohttp);
> 
> Should I have to service the httpcontext as well?
> n = lws_service(httpcontext, 10);
> 
> 
>> On 06-Dec-2016, at 10:53 PM, satya gowtham kudupudi <satyagowtham.k at gmail.com <mailto:satyagowtham.k at gmail.com>> wrote:
>> 
>> I am listening on 443 with TLS enabled. http request to 443 are being updated to https. http requests to 80 will fail. How to run a vhost on 80 and redirect to 443?
>> 
>> --
>> Gowtham
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20161207/bb33a6a7/attachment-0001.html>


More information about the Libwebsockets mailing list