Custom network and HTTPS connection to API


#1

Hey folks,

I am playing around with a custom network, and I wonder how do you get the rest-api.port to handle HTTPS (SSL) requests. My node port is 6969 and API is set to 6967.

My node server is running in Ubuntu 16.04 and Apache with a LetsEncrypt SSL certificate installed

I can connect to swagger page when browsing to port 6967 using HTTP.
If I try to use HTTPS I get this error in the node log:

    2018-12-21 17:38:07,204 WARN  [or.default-dispatcher-139] akka.actor.ActorSystemImpl - Illegal request, responding with status '501 Not Implemented': Unsupported HTTP method: ??X??>,??]!4??'?uH???[
    2018-12-21 17:38:07,217 WARN  [or.default-dispatcher-136] akka.actor.ActorSystemImpl - Illegal request, responding with status '501 Not Implemented': Unsupported HTTP method: ?R?V?????????????Q
    8o?s:?A
    2018-12-21 17:38:07,691 WARN  [or.default-dispatcher-139] akka.actor.ActorSystemImpl - Illegal request, responding with status '400 Bad Request': Unsupported HTTP method: The HTTP method started with 0x16 rather than any known HTTP method. Perhaps this was an HTTPS request sent to an HTTP endpoint?
    2018-12-21 17:38:10,458 INFO  [miner-pool-38] c.w.mining.MinerImpl - Generate MicroBlock sequence, delay = 5 seconds

So, I tried using WavesGUI client, and setting its WavesApp network settings with these values:

 network: {
                apiVersion: 'v0',
                code: 'B', /* this is my network byte */
                node: 'http://vds61135.host:6967',
                api: 'http://vds61135.host:6967',
            ......
            },

And I get the following error in Chrome console:
Access to fetch at 'http://vds61135.host:6967/assets/details/Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU' from origin 'http://vds61135.host' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.

Changing to HTTPS (using WavesCLient settings -> Network menu), I start getting an SSL protocol error in Chrome:
raven.js:1350 GET https://vds61135.host:6967/blocks/height net::ERR_SSL_PROTOCOL_ERROR

I am hosting WavesGUI in the same server as the node, and I even tried a configuration with Apache’s mod_proxy where I redirect requests on port 443 to 6967:

    ProxyVia On
    
    ServerName vds61135.host
    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPass / http://localhost:6967/
    ProxyPassReverse / http://localhost:6967/
    SSLCertificateFile /etc/letsencrypt/live/vds61135.host/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/vds61135.host/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
    

if I set to https://localhost:6967 Apache returns an error.

In the end, I just want my WavesClient to be served from HTTPS, and connect to my Nnde API using SSL, as the MainNet client does, connecting to the API at https://nodes.wavesplatform.com