我将 EC2 配置为使用 IIS 作为我的服务器的 Windows。
我只是希望在服务器上运行一个可以接收 api 请求并发送响应的 expressjs 应用程序。
我已将我的安全组配置为允许端口 3000,我已为我的 EC2 设置了 SSL 和域,我已检查我的应用程序是否正在使用
netstat -a
侦听端口 3000。
我可以通过域访问我的 ec2,例如 https://example.com 我可以用
ping www.example.com
ping它。
但是当我尝试发送请求时,我只是收到“套接字挂断”错误。
这是我的 app.js
const app = express();
const path = require("path");
const cors = require("cors");
app.use(cors);
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.get("/", function (req, res) {
res.status(200).json({
message: "success"
})
})
module.exports = app;
这是 server.js
const app = require('./app');
const port = 3000;
const server = https.createServer(app);
server.listen(port, () => {console.log(`Listening on PORT:${port}`);});
这是我用来测试 api 调用的 restful.rest 文件,两者都会导致套接字挂断
###
GET http://localhost:3000
###
GET http://example.com:3000
###
谁能告诉我为什么我收不到这个回复?
谢谢