Closed vfiee closed 2 years ago
Can you please expand on what you are requesting? Potentially with a link to an API or example?
My service is deployed in an area where the telegram service cannot be accessed without proxy configuration. Telegram notification cannot be reached. Can I access the telegram api by configuring proxy server
Interesting problem. I think proxy configuration is likely going to be something that should probably be available for all (minus email) notifications. It may be possible to reuse much of the code&work in #840 (proxies for monitors) for notifications as well.
Agree, we are able to accomplish notification to proxy relation and implement to any axios request.
There is a createAgents
method for the creation of HTTP and HTTPS agents with a given proxy entity. Proxy entities are independent of monitors, so can be related to different objects as well.
const { Proxy } = require("proxy");
// https://github.com/louislam/uptime-kuma/blob/61606650ae360e942ecd378a9311d91a49ed898d/server/proxy.js
// axios request options
const options = {};
if (proxy_id) {
const proxy = await R.load("proxy", proxy_id);
if (proxy && proxy.active) {
const { httpAgent, httpsAgent } = Proxy.createAgents(proxy);
options.proxy = false;
options.httpAgent = httpAgent;
options.httpsAgent = httpsAgent;
}
}
await axios.request(options);
I have another idea is about to use a custom Telegram API server instead of using a proxy, while proxy may down for network reasons, in this case both monitoring and notification goes down. But using a custom API server can prevent such thing happen, all you need is a properly configured nginx or Cloudflare worker deployed and you are good to go.
I have another idea is about to use a custom Telegram API server instead of using a proxy, while proxy may down for network reasons, in this case both monitoring and notification goes down. But using a custom API server can prevent such thing happen, all you need is a properly configured nginx or Cloudflare worker deployed and you are good to go.
Also, using proxy server may increase monitoring latency. Or maybe we can choose trun proxy server on or off by toggle "use for monitor", "use for notification" switch?
We are clearing up our old issues and your ticket has been open for 3 months with no activity. Remove stale label or comment or this will be closed in 2 days.
This issue was closed because it has been stalled for 2 days with no activity.
I'm looking for this feature, e.g. sending Slack webhooks or Telegram notifications over a HTTP proxy. Any news on this?
Hello, I see that it is not just me who is asking for this option in the project, in my work, which is a Hospital, the output is by proxy and I wanted to use this wonderful project but I cannot get the Telegram notifications by proxy.
Hello, I see that it is not just me who is asking for this option in the project, in my work, which is a Hospital, the output is by proxy and I wanted to use this wonderful project but I cannot get the Telegram notifications by proxy.
Well I share with you the solution I found while searching.
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
+const proxy = require("node-global-proxy").default;
class Telegram extends NotificationProvider {
name = "telegram";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
try {
let params = {
chat_id: notification.telegramChatID,
text: msg,
disable_notification: notification.telegramSendSilently ?? false,
protect_content: notification.telegramProtectContent ?? false,
};
if (notification.telegramMessageThreadID) {
params.message_thread_id = notification.telegramMessageThreadID;
}
+proxy.setConfig("http://user:password@192.168.1.254:3128");
+proxy.start();
await axios.get(`https://api.telegram.org/bot${notification.telegramBotToken}/sendMessage`, {
params: params,
});
return okMsg;
} catch (error) {
if (error.response && error.response.data && error.response.data.description) {
throw new Error(error.response.data.description);
} else {
throw new Error(error.message);
}
}
}
}
module.exports = Telegram;
and WORKING 100%
I also have the same issue
⚠️ Please verify that this bug has NOT been raised before.
🛡️ Security Policy
📝 Describe your problem
telegram proxy configuration
🐻 Uptime-Kuma Version
1.10.2
💻 Operating System and Arch
Ubuntu 20
🌐 Browser
Google Chrome
🐋 Docker Version
Docker version 20.10.5, build 55c4c88
🟩 NodeJS Version
No response