n/chit-chatu/shf_huang · 1 个月前
注册 登录
n/chit-chat · 1 个月前 · 已编辑 · 2080 次浏览
u/shf_huang铂金

免费4H8G主机保活--instabox.sh

https://instabox.sh/

instabox.sh提供了4核8G的主机,但是30分钟空闲之后就会自动停止。
可以通过cf定时任务进行保活:
创建worker

选择hello world

直接创建后编辑代码,贴入代码后重新部署

const API_ORIGIN = 'https://api.instabox.sh';
const ATTEMPTS = 3;
const REQUEST_TIMEOUT_MS = 55_000;

// Dependencies are injectable so offline tests never contact the real machine.
export async function runKeepalive(env, {
fetchImpl = fetch,
sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
} = {}) {
const key = env.INSTABOX_API_KEY;
const machineId = env.INSTABOX_MACHINE_ID;
if (typeof key !== 'string' || !/^ibk_[A-Za-z0-9_-]+$/.test(key) || key === 'ibk_REPLACE_ME') {
throw new Error('Configure the INSTABOX_API_KEY secret.');
}
if (typeof machineId !== 'string' || !/^m_[A-Za-z0-9_-]+$/.test(machineId)) {
throw new Error('Configure a valid INSTABOX_MACHINE_ID.');
}

let lastFailure = 'Request failed';
for (let attempt = 1; attempt <= ATTEMPTS; attempt++) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
let status;
let machine;
try {
const response = await fetchImpl(${API_ORIGIN}/v1/machines/${machineId}/wake, {
method: 'POST',
headers: { 'X-API-Key': key, Accept: 'application/json' },
redirect: 'manual',
signal: controller.signal,
});
status = response.status;
if (status === 200) {
machine = await response.json();
} else {
// Never log upstream response bodies, request headers or API keys.
await response.body?.cancel();
}
} catch {
// Do not propagate transport errors that might include request details.
lastFailure = 'Network, timeout or invalid JSON response';
status = undefined;
} finally {
clearTimeout(timeout);
}

if (status === 200) {
  if (machine?.id !== machineId || machine?.state !== 'running') {
    throw new Error('HTTP 200 did not confirm the expected machine is running.');
  }
  return { machineId, state: 'running', attempt };
}
if (status !== undefined) {
  lastFailure = `HTTP ${status}`;
  const retryable = status === 409 || status === 429 || status >= 500;
  if (!retryable) {
    throw new Error(`Wake rejected: HTTP ${status}. Check credentials, permissions, machine ID and account status.`);
  }
}
if (attempt < ATTEMPTS) await sleep(10_000 * attempt);

}
throw new Error(Wake failed after ${ATTEMPTS} attempts: ${lastFailure}.);
}

export default {
async scheduled(controller, env, ctx) {
// Await the job so errors are recorded as failed Cron invocations.
try {
const result = await runKeepalive(env);
console.log(JSON.stringify({ event: 'instabox_wake_ok', ...result }));
} catch (error) {
console.error(JSON.stringify({ event: 'instabox_wake_failed', message: error.message }));
throw error;
}
},
async fetch() {
// HTTP requests cannot trigger a wake or inspect secrets.
return new Response('Not found', { status: 404 });
},
};

添加变量
INSTABOX_API_KEY:

INSTABOX_MACHINE_ID

添加定时任务:

如果主机不知道用来做什么的话,可以搭建节点:
vless://7c5f288e-99c9-458d-b1c2-61be58f27f02@18081-agqurgqeoftfugqprha6jrp7je.instabox.tech:443?encryption=none&security=tls&sni=18081-agqurgqeoftfugqprha6jrp7je.instabox.tech&fp=chrome&insecure=0&allowInsecure=0&type=ws&host=18081-agqurgqeoftfugqprha6jrp7je.instabox.tech&path=%2FS-M5-4aSDFJ-DtpgVEJ_lgeeBFs#Instabox-test

10月23号官方加了8小时到期限制

通过实测cf保活可以自动唤醒机器

god:在本机做保活
test:在cf做保活

183
81
登录后参与讨论。

81 条回复

排序
  1. innc 青铜 3 YEARS 1 个月前

    这个只有15刀的额度,还不告诉你,要自己跑关机才知道

    3
  2. daai 白银 3 YEARS 1 个月前

    我靠,好阴啊

    1
  3. huhuhuhuhuhu_huhuhu 黄金 1 个月前

    谢谢,这种就让了,俺有些懒

    1
  4. hikarugoin 黄金 1 个月前

    哦这样的啊那就还是不折腾了

    1
  5. bigbigwolf 青铜 3 YEARS 1 个月前

    感谢提醒,节省时间了。

    1
  6. princelife 白银 1 个月前

    这个容器好用吗

    1
  7. shf_huang 铂金 楼主 3 YEARS 1 个月前

    我尝试部署了一个newapi:https://3000-agqurgqeoftfugqprha6jrp7je.instabox.tech

    0
  8. uixiayu 白银 1 个月前

    他还提供自带的公网链接吗

    0
  9. shf_huang 铂金 楼主 3 YEARS 1 个月前

    是的

    0
  10. 继续这个对话 →
  11. Yang-iyu 白银 1 个月前

    好像歇逼了: Error internal error

    request req_opqotyc2jktwgj66ly5cqjnr34

    1
  12. Kingjames 💘 黄金 3 YEARS 1 个月前

    又恢复了

    0
  13. DaPeng 白银 1 个月前

    已申请,等待反馈邀请码

    0
  14. Melody 白银 1 个月前

    到底有没有人获得了邀请码的?Google账号一个都没有收到

    0
  15. shf_huang 铂金 楼主 3 YEARS 1 个月前

    不清楚,反正我半天左右就收到了

    0
  16. fxz 黄金 3 YEARS 1 个月前

    感觉很随机,同一天申请的有人当天就出来,我等了3天,我还以为我是qq邮箱申请失败了呢

    0
  17. azhaoyihao 荣耀 水王 1 个月前

    我的两天才收到邀请码 听说有的人刚申请 邀请码几分钟就来了

    0
  18. Melody 白银 1 个月前

    已经快第四天了。。

    0
  19. nyoung 👑 黄金 3 YEARS 1 个月前

    搞了个3X-UI,还行

    0
  20. only 白银 3 YEARS 26 天前

    还在吗?不会吧封啊

    0
  21. nyoung 👑 黄金 3 YEARS 26 天前

    还在呀 我直接让ai给我搞的 好像是走的websocket

    0
  22. only 白银 3 YEARS 26 天前

    入站和客户端怎么配置的教一下我呗,我问ai也没解决,

    0
  23. only 白银 3 YEARS 26 天前

    3X-UI怎么配置啊?为什么我怎么搞节点都不通??

    0
  24. Arvin_Leung 🚗 荣耀 3 YEARS 1 个月前

    感谢分享教程,我还在等,不知道是不是太多人给筛选了。

    0
  25. seeq 🚧 白银 3 YEARS 1 个月前

    学习 😁

    0
  26. azhaoyihao 荣耀 水王 1 个月前

    太棒了 收藏起来

    0
  27. Splatoon 青铜 1 个月前

    直接用 UptimeRobot 做健康检查不就行了吗

    0
  28. macna40 白银 1 个月前

    image卡住了。。

    0
  29. xiapeize 铂金 3 YEARS 1 个月前

    过两天看看你的邮箱

    0
  30. okfree 白银 1 个月前

    搞了一个不会用 一直放着

    0
  31. kacey 青铜 1 个月前

    感谢分享。

    0
  32. suyongkang 钻石 2 YEARS 1 个月前

    你这个保活有点麻烦了hh

    0
  33. shf_huang 铂金 楼主 3 YEARS 1 个月前

    有个简单的,把主机的apikey扔给ai,告诉它直接帮你做保活 :xhj001:

    0
  34. suyongkang 钻石 2 YEARS 1 个月前

    hh

    0
  35. suyongkang 钻石 2 YEARS 1 个月前

    想给你回复点赞,发现找不到点赞入口了 :xhj24:

    0
  36. Rison 钻石 3 YEARS 1 个月前

    搞了一个,还不知道搞点啥呢

    0
  37. shf_huang 铂金 楼主 3 YEARS 1 个月前
    这条回复已被版主删除
  38. dwad 白银 2 YEARS 1 个月前

    保活确实麻烦的很,开了没一会就挂了

    0
  39. wxk 💯 钻石 1 个月前

    不错,等下试试

    0
  40. ketto 🔥 铂金 3 YEARS 1 个月前

    已申请差不多两天了,还没有收到邀请码

    0
  41. mitutu 白银 3 YEARS 1 个月前

    谢谢分享,我等收到邀请码后试试

    0
  42. sdcfre 钻石 3 YEARS 1 个月前

    看看

    0
  43. yukina 青铜 1 个月前

    听说有额度?

    0
  44. shf_huang 铂金 楼主 3 YEARS 1 个月前

    目前还不知道,昨晚跑到现在,目前是还在

    0
  45. awinds 黄金 不离不弃 1 个月前

    一般都活不久

    0
  46. infini 白银 不离不弃 1 个月前

    感谢分享教程

    0
  47. gubhost 钻石 钻石会员 1 个月前 已编辑

    ?我也不是上海的啊,机器ip怎么在ipsy里面写是上海的,ippure又是美国

    0
  48. feijiao 黄金 1 个月前

    我已经正常运行2天了。

    0
  49. shuai 白银 1 个月前

    不知道能活多久。

    0
  50. Jade 黄金 1 个月前

    我来看看

    0
  51. ketto 🔥 铂金 3 YEARS 1 个月前

    请问这个workers部署成功后,有什么反馈的吗?

    0
  52. shf_huang 铂金 楼主 3 YEARS 1 个月前

    这边可以看到执行成功日志

    0
  53. ketto 🔥 铂金 3 YEARS 1 个月前

    好的,谢谢哈。这个项目可以一个workers保活多台机器吗?另外8个小时过后,是不死只能手动重启机器呢?

    0
  54. Mike123 黄金 3 YEARS 1 个月前

    大佬有生成api key的选项吗,我没有找到

    0
  55. Mike123 黄金 3 YEARS 1 个月前

    现在好像没有api key这个选项了?

    0
  56. Fourth_Master 白银 1 个月前

    右上角用户名搜索“key”

    0
  57. Mike123 黄金 3 YEARS 1 个月前

    找到了,感谢

    0
  58. ketto 🔥 铂金 3 YEARS 1 个月前

    你直接在界面搜索API就可以看到

    0