1
votes

I have a website currently online. But I have a problem! The SSL work when I access the site. I see the https:// and the secure word in the URL bar but when I lunch my Nodejs app, the app grabs everything needed to work so Price and API key. But in the Google Dev Console I get his error.

GET https://csgofullcasino.com:2096/socket.io/?EIO=3&transport=polling&t=Lz6Bbpy net::ERR_ABORTED

There is the second part of the error:

Failed to load https://csgofullcasino.com:2096/socket.io/?EIO=3&transport=polling&t=Lz6BfEi: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://csgofullcasino.com' is therefore not allowed access. The response had HTTP status code 525.

I'm using the free service given by CloudFlare for my SSL and my DDOS protection. Here is my SSL code for my app.js:

//SSL INIT
var express = require('express');
var options = {
    key: fs.readFileSync('/var/www/Bot/name.key'),
    cert: fs.readFileSync('/var/www/Bot/name.crt'),
    requestCert: true
};
var app = express();
var server = require('https').createServer(options, app);
var allowedOrigins = "https://csgofullcasino.com/:*"
var io = require('socket.io').listen(server);
server.listen(2096, "0.0.0.0");
//SSL END

I also added my SSL to my apache config! Here is the apache SSL.config:

<IfModule mod_ssl.c>
    <VirtualHost _default_:2096>
        ServerAdmin [email protected]
        ServerName csgofullcasino.com
        ServerAlias csgofullcasino.com
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        SSLCertificateFile /var/www/Bot/name.crt
        SSLCertificateKeyFile /var/www/Bot/name.key
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                        SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                        SSLOptions +StdEnvVars
        </Directory>
        BrowserMatch "MSIE [2-6]" \
                        nokeepalive ssl-unclean-shutdown \
                        downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
    </VirtualHost>
</IfModule>

EDIT: I did put back the port to 443 in the SSL config, but this had no effect. Also when I add the SSL config to enable file, I can't get apache2 to restart.

I hope someone can help me Thank You, KnottyCord

1
It’s unclear what your setup is. You definitely can’t have both Apache and node listening on the same port on the same IP. What URL is your page loaded from?jcaron
That config is why I use nginx.Darkrum
@jcaron I did change later on. But I thought it was because of the Universal SSL from cloudflare so I bought an SLL certificate from Namecheap and now I get another error.KnottyCord
You need to be more explicit about what your setup is, what urls you use, what software serves what, what goes through Cloudflare (at which internal and external URLs), etc.jcaron

1 Answers

1
votes

I fix the problem by changind the ssl code from this:

//SSL INIT
var express = require('express');
var options = {
    key: fs.readFileSync('/var/www/Bot/name.key'),
    cert: fs.readFileSync('/var/www/Bot/name.crt'),
    requestCert: true
};
var app = express();
var server = require('https').createServer(options, app);
var allowedOrigins = "https://csgofullcasino.com/:*"
var io = require('socket.io').listen(server);
server.listen(2096, "0.0.0.0");
//SSL END

To this:

//SSL INIT
var express = require('express');
var options = {
    key: fs.readFileSync('/var/www/Bot/name.key'),
    cert: fs.readFileSync('/var/www/Bot/name.crt'),
    requestCert: false
};
var app = express();
var server = require('https').createServer(options, app);
var allowedOrigins = "https://csgofullcasino.com/:*"
var io = require('socket.io').listen(server);
server.listen(2096, "0.0.0.0");
//SSL END