EasyX-Community / easyNOMP

EasyNOMP - The easy NOMP mining pool - Minor development under way
https://pool.easyx.cc
GNU General Public License v2.0
56 stars 63 forks source link

SSL Support for Dashboard #142

Closed mooleshacat closed 5 years ago

mooleshacat commented 5 years ago

In the days of internet and SEO, websites needs SSL support, this is ridiculous!

Add in support to use SSL certificate.

mooleshacat commented 5 years ago

This adds problems if you use FORCE SSL on some servers and SSL is not enabled.

You end up getting stuck with a permanent redirect from HTTP -> HTTPS which HTTPS currently does not work, giving an error page.

mooleshacat commented 5 years ago

Code is nearly done:

/* HTTP WEBSITE */
app.listen(portalConfig.website.port, portalConfig.website.host, function () {
    logger.info('Website started on %s:%s', portalConfig.website.host,portalConfig.website.port);
});

/* HTTPS WEBSITE */ 
if (portalConfig.website.sslenabled) {                 
    var privateKey = fs.readFileSync( portalConfig.website.sslkey );
        var certificate = fs.readFileSync( portalConfig.website.sslcert );          
        https.createServer({
            key: privateKey,
            cert: certificate
        }, app).listen(portalConfig.website.sslport, portalConfig.website.host, function () {
        logger.info('SSL Website started on %s:%s', portalConfig.website.host,portalConfig.website.sslport);
    });
}

Just taking my time :P

mooleshacat commented 5 years ago
                                                Network Connected:      Mainnet
                                                Detected Reward Type:   POW
                                                Current Block Height:   86035
                                                Current Connect Peers:  undefined
                                                Current Block Diff:     100890.339704832
                                                Network Difficulty:     95163.11619250198
                                                Network Hash Rate:      54.76 MH
                                                Stratum Port(s):        20000, 20001, 20002, 20003
                                                Pool Fee Percent:       0%
                                                Block polling every:    1000 ms
[2018-11-02T11:40:11.672Z] [info] [ravencoin] [Pool [:1]] : Stratum Pool Server Started for ravencoin [RVN] {x16r}
                                                Network Connected:      Mainnet
                                                Detected Reward Type:   POW
                                                Current Block Height:   431005
                                                Current Connect Peers:  undefined
                                                Current Block Diff:     21410528.12026573
                                                Network Difficulty:     21370162.30437318
                                                Network Hash Rate:      5.85 TH
                                                Stratum Port(s):        20020, 20021, 20022, 20023
                                                Pool Fee Percent:       0%
                                                Block polling every:    1000 ms
[2018-11-02T11:40:11.939Z] [warn] [ravencoin] [Pool [:2]] : No rewardRecipients have been setup which means no fees will be taken
[2018-11-02T11:40:11.942Z] [warn] [mogwaicoin] [Pool [:2]] : No rewardRecipients have been setup which means no fees will be taken
[2018-11-02T11:40:11.955Z] [info] [ravencoin] [Pool [:2]] : Stratum Pool Server Started for ravencoin [RVN] {x16r}
[2018-11-02T11:40:11.956Z] [info] [mogwaicoin] [Pool [:2]] : Stratum Pool Server Started for mogwaicoin [MOG] {neoscrypt}
[2018-11-02T11:40:12.855Z] [info] [system] [CLI] : CLI listening on 0.0.0.0:17117
[2018-11-02T11:40:13.450Z] [info] [system] [Website] : Starting Website module
[2018-11-02T11:40:13.454Z] [info] [system] [Stats] : Starting Stats Module...
[2018-11-02T11:40:13.469Z] [info] [system] [Website] : Attempting to start Website on 0.0.0.0:44420
[2018-11-02T11:40:13.471Z] [info] [system] [Website] : Attempting to start SSL Website on 0.0.0.0:44421
[2018-11-02T11:40:13.493Z] [info] [system] [Website] : Website started on 0.0.0.0:44420
[2018-11-02T11:40:13.469Z] [info] [system] [Website] : Attempting to start Website on 0.0.0.0:44420
[2018-11-02T11:40:13.471Z] [info] [system] [Website] : Attempting to start SSL Website on 0.0.0.0:44421
[2018-11-02T11:40:13.493Z] [info] [system] [Website] : Website started on 0.0.0.0:44420

Probably cert/key issue...

mooleshacat commented 5 years ago
[2018-11-02T11:59:16.301Z] [info] [system] [Website] : Attempting to start Website on 0.0.0.0:44420
[2018-11-02T11:59:16.303Z] [info] [system] [Website] : Attempting to start SSL Website on 0.0.0.0:44421
[2018-11-02T11:59:16.306Z] [info] [system] [PaymentProcessing] : Payment processing setup to run every 120 second(s) with daemon (kthx@127.0.0.1:19000) and redis (127.0.0.1:6379)
[2018-11-02T11:59:16.306Z] [info] [system] [PaymentProcessing] : Payment processing setup to run every 120 second(s) with daemon (kthx@127.0.0.1:19002) and redis (127.0.0.1:6379)
[2018-11-02T11:59:16.316Z] [info] [system] [Website] : Website started on 0.0.0.0:44420
[2018-11-02T11:59:16.316Z] [info] [system] [Website] : SSL Website started on 0.0.0.0:44421

It was my certificates were not right user/permissions

https://miningpool.easyx.info:44421/

mooleshacat commented 5 years ago

SSL is enabled and pushed to master repo.

I have been able to get SSL working on NON standard ports.

In order to get ports 80 and 443 working you must be root. I am working on moving my install over to root user to fix this.

Until I get this working on standard ports for testing I will keep this open.

mooleshacat commented 5 years ago

Working on standard ports:

https://miningpool.easyx.info/ http://miningpool.easyx.info/

Only docs left, not tracking those in issue tracker.

mooleshacat commented 5 years ago

Reopened: Forgot "forcessl" feature is not yet done...

mooleshacat commented 5 years ago

Update ticket here https://github.com/zone117x/node-open-mining-portal/issues/57 when done

mooleshacat commented 5 years ago

Added to index.html:

<!-- LeshaCat: We now need to decide if we are currently SSL and then if not and forcing SSL, redirect to SSL port. -->
<script type="text/javascript" >
if (({{=it.portalConfig.website.sslenabled}}) & (location.protocol === 'http:')) {
// similar behavior as clicking on a link
window.location.href = "https://{{=it.portalConfig.website.stratumHost}}:{{=it.portalConfig.website.sslport}}/";
}
</script>
<!-- LeshaCat: We now need to decide if we are currently SSL and then if not and forcing SSL, redirect to SSL port. -->

Cest Complete

mooleshacat commented 5 years ago

That last posted code has bug in it... Sorting it out before PR's made.

mooleshacat commented 5 years ago

Working on higher priority issue - more severe bugs in API

Will resume later

mooleshacat commented 5 years ago

I believe this is finished... Only changed the condition to rely upon sslforced instead of sslenabled

SSL when enabled should not force to SSL unless sslforce enabled.

Server has been using SSL with Let's Encrypt for a while now, testing gone OK. Closing ticket unless further issues.