I'm trying to create a simple https server on Amazon EC2 to test a third party API.
Here are the steps I've followed:
openssl genrsa 2048 > privatekey.pem
openssl req -new -key privatekey.pem -out csr.pem
openssl x509 -req -days 365 -in csr.pem -signkey privatekey.pem -out server.crt
var https = require('https'); var fs = require('fs'); var options = { key: fs.readFileSync('./privatekey.pem'), cert: fs.readFileSync('./server.crt') }; https.createServer(options, function (req, res) { res.writeHead(200); res.end("hello world\\n"); }).listen(8080);
When I run the server, and attempt to connect to it using url https://ec2-XX-XXX-XXX-XXX.compute-1.amazonaws.com/ , I keep getting a connection refused.
A telnet test also produces:
Trying XX.XXX.XXX.XXX...
telnet: connect to address XX.XXX.XXX.XXX: Connection refused
telnet: Unable to connect to remote host
Can someone please tell me what I need to fix to enable https on this EC2 instance?
更改你的listen(8080)
以listen(443)
除非你有一个web服务器在443上监听并在8080上向节点发送请求。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.