58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
import { Client } from 'ssh2';
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 检查所有Nginx配置 ===\n');
|
|
|
|
conn.exec('ls -la /www/server/panel/vhost/nginx/', (err, stream) => {
|
|
if (err) {
|
|
console.log('配置目录检查失败:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
stream.on('data', (data) => {
|
|
console.log('配置文件:', data.toString());
|
|
});
|
|
|
|
stream.on('close', () => {
|
|
conn.exec('cat /www/server/nginx/conf/nginx.conf | head -100', (err, stream2) => {
|
|
if (err) {
|
|
console.log('主配置检查失败:', err.message);
|
|
} else {
|
|
stream2.on('data', (data2) => {
|
|
console.log('\n主配置:', data2.toString());
|
|
});
|
|
}
|
|
|
|
stream2.on('close', () => {
|
|
conn.exec('grep -r "redirect" /www/server/panel/vhost/nginx/ 2>/dev/null', (err, stream3) => {
|
|
if (err) {
|
|
console.log('重定向检查失败:', err.message);
|
|
} else {
|
|
stream3.on('data', (data3) => {
|
|
console.log('\n重定向规则:', data3.toString());
|
|
});
|
|
}
|
|
|
|
stream3.on('close', () => {
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.log('连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect({
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
}); |