[英]Why do I have to type the “:80” in https://localhost:80 for my website to load?
I recently secured my website on node.js to use https instead of just plain http. 最近,我在node.js上确保我的网站使用https而不是纯http。 However, once I did this, I realized that I had to type out the :80 suffix if I wanted to get to my website to load.
但是,一旦这样做,我意识到如果要访问我的网站,则必须输入:80后缀。 Why is this?
为什么是这样? Doesn't chrome default to port 80 and shouldn't https://localhost suffice?
chrome不会默认使用端口80,并且https:// localhost是否足够?
const port = 80;
https.createServer({
key: fs.readFileSync('./private/ssl/server.key'),
cert: fs.readFileSync('./private/ssl/server.cert')
}, app)
.listen(port, function () {
console.log('Server running on port: ' + port);
});
app.get('/', (req, res) => {
res.sendFile('index.html', { root: path.join(__dirname, './') });
});
app.use(express.static('./public'));```
HTTPS的默认端口是443,而不是80。
Be aware that HTTPS uses port 443 by default, and that's probably the source of your confusion. 请注意,默认情况下HTTPS使用端口443,这可能是造成混乱的原因。
If you specify both https
and :80
in your browser's address bar, you are making an HTTPS request to port 80, which is unusual. 如果在浏览器的地址栏中同时指定
https
和:80
,则您正在向端口80发出HTTPS请求,这很常见。 What kind of reply you will be getting depends on your server's configuration. 您将获得什么样的答复取决于服务器的配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.