这是我第一次部署ssl。我有express节点js模块运行在localhost:4000。我已经生成了自签名证书并安装在服务器中并且正在工作。现在,我的angularjs前端运行在localhost:3000上(我使用http-server来运行角码)。Angular + Node(Express)+ SSL集成
为了使我的观点更清晰,这里是在服务器端的代码: -
// Import node js modules
var https = require('https')
var fs = require('fs')
var express = require('express')
// Load App configuration
var config = require('./config/config')
// Database Integration Here(mongodb)
// Initialize the express app
var app = express()
// App express Configuration
// parse application/json
app.use(bodyParser.json())
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true}))
app.use(cors())
app.set('serverHost', config.server.host)
app.set('serverPort', config.server.port)
app.set('serverUrl', config.server.url)
// Initializing various app modules
// Initialize the components
//Initialize the route(controller)
// Start the app with a given port no and mode
var env = process.env.NODE_ENV || 'development'
var httpsOptions = {
key: fs.readFileSync(__dirname + '/cert/server.key'),
cert: fs.readFileSync(__dirname + '/cert/server.crt')
}
https.createServer(httpsOptions, app).listen(app.get('serverPort'), function() {
// Server and mode info
console.log('The homerungurus backend running on server: '
+ app.get('serverHost')
+ ' and the port is: '
+ app.get('serverPort'))
console.log("The mode is: " + env)
})
正如你可以看到我已经安装在服务器的证书。 我并不需要一个HTTP代理,因为我要在标准端口443
我无法理解一些事情上部署Web服务器角 -
- 如何启用并设置SSL证书在我的角度模块中,以便 express和angular可以通过ssl进行通信。
- 我如何向浏览器显示我的后端express节点的证书?
我希望我已经说得更清楚了。
任何帮助表示赞赏?
请提供更多代码以便我们为您提供帮助:** [MCVE](http://stackoverflow.com/help/mcve)** – AGE
@AGE我已添加更多内容。希望这将是足够的。 – tumulr