This tutorial is not about how to setup and configure your Discord server itself and it requires Page Rules. In case you did not use Page Rules before to redirect requests or want to know more about it, read this tutorial. .
Even though there’s the above mentioned tutorial, I decided to create this one especially for Discord users as this question comes up from time to time. Forwarding a subdomain to a discord invitelink is pretty easy and takes just a few minutes.
Create a new subdomain in the DNS App. If youre unfamiliar or unsure how to add DNS records have a look at this tutorial.
Point it to any public IP address you like, except Cloudflare IPs such as 18.104.22.168.
Get your Discord invite URL and ensure it will not expire:
Go back to your Cloudflare dashboard and create a new Page Rule.
[email protected]:~$ curl -I http://discord.yourdomain.com HTTP/1.1 301 Moved Permanently Date: Sat, 25 Jan 2020 11:30:46 GMT Connection: keep-alive Cache-Control: max-age=3600 Expires: Sat, 25 Jan 2020 12:30:46 GMT Location: https://discord.gg/9RBxxxxx Alt-Svc: h3-24=":443"; ma=86400, h3-23=":443"; ma=86400 Server: cloudflare CF-RAY: 55a9eac1bcc1befb-FRA
If you choose an invite link that expires, you’ll need to edit this Page Rule and replace the invite URL.