39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
const express = require('express');
|
|||
|
|
const app = express();
|
||
|
|
const PORT = 80;
|
||
|
|
|
||
|
|
// 简单测试页面
|
||
|
|
app.get('/', (req, res) => {
|
||
|
|
res.send(`
|
||
|
|
<!DOCTYPE html>
|
||
|
|
<html>
|
||
|
|
<head><title>测试 - 端口80</title><meta charset="utf-8"></head>
|
||
|
|
<body style="font-family: Arial; padding: 40px;">
|
||
|
|
<h1>✅ 端口80测试成功!</h1>
|
||
|
|
<p>服务器: 43.161.248.209:80</p>
|
||
|
|
<p>时间: ${new Date().toISOString()}</p>
|
||
|
|
<h2>🔗 系统访问链接:</h2>
|
||
|
|
<ul>
|
||
|
|
<li><a href="http://43.161.248.209:5000/app/index.html">主应用 (端口5000)</a></li>
|
||
|
|
<li><a href="http://43.161.248.209:5000/test">测试页面</a></li>
|
||
|
|
<li><a href="http://43.161.248.209:5000/api/health">健康检查</a></li>
|
||
|
|
</ul>
|
||
|
|
<h2>🔧 问题诊断:</h2>
|
||
|
|
<p>如果端口5000无法访问,可能是安全组阻止。请检查腾讯云安全组规则,确保端口5000已开放。</p>
|
||
|
|
</body>
|
||
|
|
</html>
|
||
|
|
`);
|
||
|
|
});
|
||
|
|
|
||
|
|
// 启动服务器(需要root权限)
|
||
|
|
if (PORT === 80) {
|
||
|
|
console.log('⚠️ 端口80需要root权限,使用sudo运行');
|
||
|
|
app.listen(PORT, '0.0.0.0', () => {
|
||
|
|
console.log(`测试服务器运行在: http://0.0.0.0:${PORT}`);
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
app.listen(PORT, '0.0.0.0', () => {
|
||
|
|
console.log(`测试服务器运行在: http://0.0.0.0:${PORT}`);
|
||
|
|
});
|
||
|
|
}
|