Files
huishou/fix-nginx-root.js
2026-07-27 14:07:26 +08:00

33 lines
1.2 KiB
JavaScript

const { Client } = require('ssh2');
const conn = new Client();
conn.on('ready', () => {
console.log('=== 删除容器内默认index.html ===');
conn.exec('docker exec huishou rm /usr/share/nginx/html/index.html', (err, stream) => {
if (err) { console.log('ERR:', err); conn.end(); return; }
stream.on('close', () => {
console.log('默认index.html已删除');
console.log('\n=== 验证删除 ===');
conn.exec('docker exec huishou ls -la /usr/share/nginx/html/', (err2, stream2) => {
if (err2) { console.log('ERR2:', err2); conn.end(); return; }
stream2.on('data', (d) => console.log(d.toString()));
stream2.on('close', () => {
console.log('\n=== 测试HTTP访问 ===');
conn.exec('curl -s http://127.0.0.1:4001/ | head -5', (err3, stream3) => {
if (err3) { console.log('ERR3:', err3); conn.end(); return; }
stream3.on('data', (d) => console.log(d.toString()));
stream3.on('close', () => {
console.log('\n✅ 修复完成!');
conn.end();
});
});
});
});
});
});
});
conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' });