SSL 不适用于 Node.js 应用

SSL not working with Node.js app

我有一个网站目前在线。但是我有一个问题!当我访问该站点时,SSL 工作。我在 URL 栏中看到了 https:// 和安全词,但是当我午餐我的 Nodejs 应用程序时,该应用程序会获取工作所需的一切,因此 Price 和 API 密钥。但是在 Google 开发控制台中我得到了他的错误。

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

还有第二部分的错误:

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.

我正在使用 CloudFlare 提供的免费服务来保护我的 SSL 和 DDOS。 这是我的 app.js:

的 SSL 代码
//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

我还将我的 SSL 添加到我的 apache 配置中! 这是阿帕奇 SSL.config:

<IfModule mod_ssl.c>
    <VirtualHost _default_:2096>
        ServerAdmin csgofullcasino@gmail.com
        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>

编辑:我确实在 SSL 配置中将端口放回 443,但这没有任何效果。此外,当我添加 SSL 配置以启用文件时,我无法让 apache2 重新启动。

希望有人能帮助我 谢谢你, 结绳

我通过更改 ssl 代码解决了这个问题:

//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

为此:

//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