我的网站目前在线。但我有一个问题!当我访问该站点时,SSL工作。我在网址栏中看到了https://和安全词,但是当我在我的Nodejs应用程序中吃午饭时,该应用程序会抓取所有工作所需的价格和API密钥。但是在Google Dev Console中我得到了他的错误。
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配置中! 这是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重新启动。
我希望有人可以帮助我 谢谢, KnottyCord
答案 0 :(得分:0)
我通过改变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