Allow HTTPS traffic to Amazon EC2 instance

0

Hello, I'm having issues allowing traffic through HTTPS to my Ubuntu EC2 instance, where I want to run an app that creates a server using Express.js. This instance already has a domain name defined with its corresponding SSL certificates installed. When I try to start the server, I encounter this issue, and I'm not sure how to resolve it.

screenshot screenshot

1 Answer
1

You cannot use your global IP or your public DNS name as your hostname, but you can set hostname to 0.0.0.0 to serve your app globally.

const http = require("http");

const hostname = "0.0.0.0";
const port = 8000;

const server = http.createServer((req, res) => {
  res.writeHead(200, { "Content-Type": "text/plain" });
  res.end("Hello World\n");
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});
profile picture
HS
answered 7 months ago
profile picture
EXPERT
reviewed 7 months ago
profile picture
EXPERT
reviewed 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions