2012-10-16 34 views
2

我在我的網站上有一個通知系統,我正在嘗試將它從http更改爲https。將通知系統更改爲SSL(目前在Chrome中使用https時因爲使用http而被阻止)

但是我的app.js現在列出到端口8888。

有沒有一個快速的方法,我可以修改它?我在網上嘗試了幾種方法,但沒有成功。

(我現在的捲曲是一樣的東西http://myipaddress:8888

非常感謝!對此,我真的非常感激。

/* CONFIGURATION */ 

/* Web Server Config */ 
var _postpath = '/send'; 
var _listenport = 8888; 
var _listenaddr = '0.0.0.0'; //use '0.0.0.0' to listen on all interfaces 

/* Slave (sub) Redis Server Config */ 
var _channelfilter = '*'; 
var _sub_db_addr = '127.0.0.1'; 
var _sub_db_passwd_protected = true; 
var _sub_db_passwd = 'mypassword'; 
var _sub_db_port = 6379; //default redis port is 6379 

/* Master (pub) Redis Server Config */ 
var _pub_db_addr = '127.0.0.1'; 
var _pub_db_passwd_protected = true; 
var _pub_db_passwd = 'mypassword'; 
var _pub_db_port = 6379; //default redis port is 6379 

/* add pub.auth(_pub_db_passwd) in function to enable password 


/* SocketIO Config */ 
var _loglevel = 1; 

/* simple-pub-sub Config */ 
var _secretkey = "mypassword"; 


/* SERVER CODE -- DO NOT MODIFY */ 
redis = require('redis'); 
express = require('express'); 
socketio = require('socket.io'); 
fs = require("fs"), 
pub = redis.createClient(_pub_db_port, _pub_db_addr); if (_pub_db_passwd_protected) { } 

sub = redis.createClient(_sub_db_port, _sub_db_addr); if (_sub_db_passwd_protected) { } 
sub.on("pmessage", function(pattern, channel, json) { io.sockets.volatile.emit(channel, JSON.parse(json)); }); 
sub.psubscribe('*'); 

app = express.createServer(express.static(__dirname + '/public'),express.bodyParser()); 
app.listen(_listenport, _listenaddr); 
app.post(_postpath, function(req, res){ 
    if(req.body.secretkey==_secretkey){ 
    delete req.body.secretkey; pub.publish(req.body.channel, JSON.stringify(req.body)); 
    res.send(200); 
    } 
}); 

io = socketio.listen(app); 
io.configure(function() { io.set('log level', _loglevel) }); 

回答

1

我剛找到解決方案。

var options = { 
    key: fs.readFileSync('/home/ec2-user/privatekey.pem'), 
    cert: fs.readFileSync('/home/ec2-user/certificate.pem') 
}; 


app = express.createServer(options, express.static(__dirname + '/public'),express.bodyParser()); 
+0

您也可以強制使用express-force-domain npm包。 – chovy

相關問題