docs(log): add iteration log for proxy white-labeling and service fix

This commit is contained in:
rafif committed 2026-07-31 10:59:47 +07:00
1 parent 8e58db970f
commit 09cc05829e
7 files changed
+227

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
const { Client } = require('ssh2');
const conn = new Client();
conn.on('ready', () => {
conn.exec("cat /home/adminbackend/web/demoplace.my.id/public_html/.htaccess", (err, stream) => {
stream.on('data', (d) => process.stdout.write(d));
stream.on('close', () => conn.end());
});
}).connect({ host: '103.185.47.52', port: 2222, username: 'adminbackend', password: 'htEo7x6LsBQiEHHH' });
+8
View File
@@ -0,0 +1,8 @@
const { Client } = require('ssh2');
const conn = new Client();
conn.on('ready', () => {
conn.exec("cat /home/adminbackend/web/demoplace.my.id/public_html/proxy.php", (err, stream) => {
stream.on('data', (d) => process.stdout.write(d));
stream.on('close', () => conn.end());
});
}).connect({ host: '103.185.47.52', port: 2222, username: 'adminbackend', password: 'htEo7x6LsBQiEHHH' });
+26
View File
@@ -0,0 +1,26 @@
// scripts/clean-remote-backup-files.js
const { Client } = require('ssh2');
const CONFIG = {
host: '103.185.47.52',
port: 2222,
username: 'adminbackend',
password: 'htEo7x6LsBQiEHHH',
};
async function main() {
const ssh = new Client();
ssh.on('ready', () => {
console.log('[SSH] Connected. Removing old backup files...');
const cmd = 'rm -f /home/adminbackend/web/demoplace.my.id/public_html/*.bak /home/adminbackend/web/demoplace.my.id/public_html/*~ && echo "Backup files removed cleanly"';
ssh.exec(cmd, (err, stream) => {
if (err) throw err;
stream.on('data', (d) => process.stdout.write(d));
stream.on('close', () => {
ssh.end();
});
});
}).connect({ host: CONFIG.host, port: CONFIG.port, username: CONFIG.username, password: CONFIG.password });
}
main().catch(console.error);
+48
View File
@@ -0,0 +1,48 @@
// scripts/diagnose-remote-server.js
const { Client } = require('ssh2');
const CONFIG = {
host: '103.185.47.52',
port: 2222,
username: 'adminbackend',
password: 'htEo7x6LsBQiEHHH',
};
function execCmd(ssh, cmd) {
return new Promise((resolve) => {
console.log(`\n========================================`);
console.log(`EXEC: ${cmd}`);
console.log(`========================================`);
ssh.exec(cmd, (err, stream) => {
if (err) {
console.error('Exec error:', err.message);
return resolve('');
}
let out = '';
stream.on('data', (d) => { out += d; process.stdout.write(d); });
stream.stderr.on('data', (d) => { out += d; process.stderr.write(d); });
stream.on('close', () => resolve(out));
});
});
}
async function main() {
const ssh = new Client();
ssh.on('ready', async () => {
console.log('[SSH] Connected for deep diagnosis...');
await execCmd(ssh, 'grep -rn "Gagal terhubung" /home/adminbackend/ /var/www/ /etc/ 2>/dev/null');
await execCmd(ssh, 'ls -la /home/adminbackend/web/demoplace.my.id/public_html/');
await execCmd(ssh, 'cat /home/adminbackend/web/demoplace.my.id/public_html/index.php');
await execCmd(ssh, '/home/adminbackend/.npm-global/bin/pm2 list');
await execCmd(ssh, '/home/adminbackend/.npm-global/bin/pm2 logs backone-frontend --lines 30 --raw');
await execCmd(ssh, 'curl -I http://127.0.0.1:3000/login');
await execCmd(ssh, 'curl -I http://127.0.0.1:8080/login');
await execCmd(ssh, 'curl -k -I https://103.185.47.52:8443/login');
await execCmd(ssh, 'curl -s https://demoplace.my.id/login | head -n 30');
ssh.end();
}).connect({ host: CONFIG.host, port: CONFIG.port, username: CONFIG.username, password: CONFIG.password });
}
main().catch(console.error);
+77
View File
@@ -0,0 +1,77 @@
// scripts/fix-proxy-php.js
const { Client } = require('ssh2');
const CONFIG = {
host: '103.185.47.52',
port: 2222,
username: 'adminbackend',
password: 'htEo7x6LsBQiEHHH',
};
const cleanProxyPhpCode = `<?php
// proxy.php — Reverse proxy to BackOne Dashboard Engine on port 3000
$target = 'http://127.0.0.1:3000' . $_SERVER['REQUEST_URI'];
$ch = curl_init($target);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 45);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $_SERVER['REQUEST_METHOD']);
// Forward headers
$req_headers = array();
foreach (getallheaders() as $k => $v) {
if (strtolower($k) !== 'host') {
$req_headers[] = "$k: $v";
}
}
$req_headers[] = "Host: demoplace.my.id";
curl_setopt($ch, CURLOPT_HTTPHEADER, $req_headers);
// Forward body
if (in_array($_SERVER['REQUEST_METHOD'], array('POST', 'PUT', 'PATCH'))) {
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('php://input'));
}
$resp = curl_exec($ch);
if ($resp === false) {
http_response_code(502);
die("BackOne Dashboard: Service temporarily unavailable (502 Gateway Timeout). Please try refreshing in a few seconds.");
}
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$resp_headers = substr($resp, 0, $header_size);
$body = substr($resp, $header_size);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
http_response_code($status);
foreach (explode("\r\n", $resp_headers) as $h) {
if ($h && !str_starts_with($h, 'HTTP/') && !str_starts_with(strtolower($h), 'transfer-encoding:')) {
header($h, false);
}
}
echo $body;
?>
`;
async function main() {
const ssh = new Client();
ssh.on('ready', () => {
console.log('[SSH] Connected. Updating proxy.php on server...');
const command = `cat << 'EOF' > /home/adminbackend/web/demoplace.my.id/public_html/proxy.php\n${cleanProxyPhpCode}\nEOF`;
ssh.exec(command, (err, stream) => {
if (err) throw err;
stream.on('data', (d) => process.stdout.write(d));
stream.on('close', () => {
console.log('\n[OK] proxy.php updated cleanly with white-labeling compliance!');
ssh.end();
});
});
}).connect({ host: CONFIG.host, port: CONFIG.port, username: CONFIG.username, password: CONFIG.password });
}
main().catch(console.error);
+24
View File
@@ -0,0 +1,24 @@
const { Client } = require('ssh2');
const CONFIG = {
host: '103.185.47.52',
port: 2222,
username: 'adminbackend',
password: 'htEo7x6LsBQiEHHH',
};
async function main() {
const ssh = new Client();
ssh.on('ready', () => {
console.log('[SSH] Connected. Testing live HTTP endpoint...');
ssh.exec('curl -s -I https://demoplace.my.id/login; echo "---"; curl -s https://demoplace.my.id/login | head -n 15', (err, stream) => {
if (err) throw err;
stream.on('data', (d) => process.stdout.write(d));
stream.on('close', () => {
ssh.end();
});
});
}).connect({ host: CONFIG.host, port: CONFIG.port, username: CONFIG.username, password: CONFIG.password });
}
main().catch(console.error);