Thank you for this, can you also show us how to set up a proxy server with a VPS ourselves
EDIT: grammar
Thank you for this, can you also show us how to set up a proxy server with a VPS ourselves
EDIT: grammar
To host it yourself:
This setup just exposes the proxy publicly with no reverse proxy. Recommended to start with only, but you should probably use the correct setup as soon as possible.
Node.js
on your server. This can be done through a package manager or through nvm
. The minimum requirement is v16.git
. This is usually a default tool nowadays, but just grab it off of your package manager if you donāt have it.Redis
or its Windows equivalent Memurai
(please note Memurai is paid software and you should probably just go put Redis in a Docker container instead on Windows, however for testing purposes Memurai will work fine). You need at least v6.2 due to the commands used, though v7 and above is preferable.pm2
and yarn
(npm i -g pm2 yarn
)git clone https://github.com/LewisTehMinerz/webhook-proxy
to clone the proxy.webhook-proxy
folder..example.json
files to the same name, just without .example
(e.g., config.example.json
ā config.json
).config.json
.yarn && yarn build
. This will install the necessary dependencies and build the project.pm2 start dist/index.js --name=webhook-proxy
. This will start the app under the name webhook-proxy
in pm2.
pm2 startup
, follow the instructions there, and then run pm2 save
.yarn update
.This setup involves using a reverse proxy instead of exposing the server directly and using a cluster instead of a single process. This is recommended (and the correct way), but a bit more complicated. This is how I actually run the proxy. This is how I used to run the proxy. Iām now using Cloudflare Tunnel, however this is still the recommended way of doing things that keeps it simple.
nginx
. This will be our front-facing web server.trustProxy
to true
.nginx
with the following configuration:server {
listen 80;
server_name <domain name>;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:<port>;
proxy_redirect off;
}
}
(it is recommended you enable SSL and HTTP2 but this is out of scope for this setup)
nginx
and pm2 restart webhook-proxy
. You should be good to go.pm2 delete webhook-proxy
, and then run pm2 start dist/index.js --name=webhook-proxy -i 1
. This will run it in a clustered mode instead of the standard fork
mode.
pm2 scale webhook-proxy <worker count>
. This is good for games that are growing that need to send a lot of webhook requests as you can just put on more workers as needed.A new feature of the proxy is the queue system. This requires some extra (but simple) setup.
pm2 restart webhook-proxy
).pm2 start dist/queueProcessor.js --name=webhook-proxy-processor
.
pm2 save
as well if necessary./queue
onto your webhook requests!With the newer updates of the proxy, you can now just run yarn update
and, as long as you have the setup as described in this guide, it will automatically update the proxy for you. If a yarn update
fails, try running it again. It could be that I updated the script.
When discordapp falls through, this proxy will be a good fallback. Thanks again.
This is really helpful and all, but I think you could make this a little more efficient by using ProxyService.
This could be used as a means to provide a global proxy, instead of selectively using it for webhooks. This can help if you want to access APIs or such outside of Robloxās useragent. I personally set it up and it was the same amount of work as this. Theyāre both doing essentially the same thing but yea. Thought Iād contribute that, however, good post. This is very helpful.
The point is to avoid running a ProxyService instance. I donāt want people using my server to make any web request they want. I wanted to keep the focus restricted to webhooks so that people canāt use my server to perform malicious web requests.
It would also mean I have to give out access keys, whilst this is publicly accessible.
Your proxy no longer works now. Itās got some server-sided 502 gateway issue going on. discordapp.com is now a 403 too, so itās getting challenging.
Tried using your proxy, and this is what resulted:
https://gyazo.com/83364b86967f46a1cc0238f2c2579497
Probably because this is what is being fed into the webhook, Iād assume:
local mkt = game:GetService("MarketplaceService")
local assetInfo = mkt:GetProductInfo(game.PlaceId,0)
local Data =
{
["username"] = "Frigus Cop";
["content"] = "",
["embeds"] = {{
["title"] = "**Suspected Exploiter Kicked**",
["description"] = p.Name.."has been banned from "..assetInfo.Name,
["type"] = "rich",
["color"] = tonumber(0xFF8C00),
["fields"] = {
{
["name"] = "plr Name",
["value"] = p.Name,
["inline"] = true
},
{
["name"] = "plr UserId",
["value"] = p.UserId,
["inline"] = true
},
{
["name"] = "Exploit Probability",
["value"] = severity,
["inline"] = true
},
{
["name"] = "Account Age",
["value"] = p.AccountAge.." Days",
["inline"] = true
},
{
["name"] = "**Link to Profile**",
["value"] = "https://www.roblox.com/users/"..p.UserId.."/profile",
["inline"] = true
},
{
["name"] = "Banned?",
["value"] = "yes",
["inline"] = true
},
},
}}
}
Data = HTTPService:JSONEncode(Data)
HTTPService:PostAsync(link, Data)
If I have to simplify that into a short message instead (which is probably it), I think I will just use Guilded to log this stuff. All Iām doing with the webhooks is logging potential exploiters, admin command usage, and if an exploiter who was autobanned tried rejoining the game afterwards.
Iām not sure what āTrust check failedā is. However, the proxy is currently down for unscheduled maintenance. Iāll bring it back up as soon as I can.
The proxy is back up. Sorry for the downtime.
I continue to have the same message occur.
Please DM me with the message you receive so we can resolve this, alongside a code sample.
@CoolJohnnyboy If you canāt tell by the reply I gave you, Iām exhausted. Phew!
I did some research into your issue, you seem to be missing https://
off of the link. HTTPService doesnāt really like this much. Can you try adding it and seeing what happens?
discordapp has fallen. (Now I, Starscream, lead the Decepticons!)
Confirming for any future posters that this proxy is working. If youāre having issues, doublecheck your webhook URL. Remember to include https:// and that all thatās replaced with the proxyās URL is discord.com or discordapp.com.
Thank you this has been a life saver for group
Iāll be hosting your proxy on rblx-discord-webhook.us-3.evennode.com . That will save time on behalf of game developers who would have to host it themselves.
Works great now. Thanks for the effort dude! I really appreciate it
Hey all,
Iām experimenting with a new feature. If you put /queue
onto the end of your webhook URLs, your messages will be put into a RabbitMQ queue instead of being sent directly to Discord.
These queued messages are guaranteed to be sent, but are not guaranteed to be in order (though I try, promise!). If order matters, this isnāt for you.
Speaking of ratelimits, there is a much higher ratelimit for queueing messages rather than sending them directly: 10/1s. Compared to Discordās 5/2s, this is very generous, and it doesnāt even stop your requests if you hit it, it just slows them down. Many benefits with few drawbacks!
Oh, right, if you use ?wait=true
, that doesnāt work with this. You should treat this as fire-and-forget. If you want message data back, you canāt use the queue system.
Of course, if this system doesnāt end up panning out Iāll provide a one week notice that Iāll be removing it. However, I have high hopes, and hopefully you guys will get some use out of it, especially if you get ratelimited a lot.
Have fun! As usual, report any issues here or on GitHub.
Thank you for this, I use webhooks for game analytics and I was worried that I wouldnāt be able to do that anymore.
Iām back~
I got bored, have this module:
https://gist.github.com/LewisTehMinerz/5308748d2d65a195ff580d4b9a54845f
It should make it a bit simpler to send messages.
local proxy = Proxy.new(id, token)
proxy:Send({ content = "abc" }, false)
proxy:Queue({ content = "abc" })
ā¦ will send abc
to the webhook, both directly and via the queue system.
As usual, report any issues here or on GitHub.