/ Writeups

Setting aside a subdomain for my Discord Server


So, I recently saw a livestream from Riccio, just having had completed a stream myself (you should've been there, it was a lot of fun!). While I ended up catching it right as it was ending, I noted the following thing on his title card:

Don't you look pretty now? (A discord.gg vanity URL)

Naturally I was curious as to how someone like myself could get a vanity URL from Discord, so that if a viewer wanted to get involved, it's easy! A little bit of googling led to this page:

Don't read the changelog for Discord if you're turned off by words like 'fam'. (Join and get 'partner-only' tools!)

Discord probably decided that good tools should really only go to people that can bring in money since they're probably running at a too high a cost to do it for everyone:

This is probably the only interesting feature for me. ('Welcome new members to your server with custom splash art of your choosing and a personal discord.gg link to call your own.')

It's probably for the best they don't let any server reserve invite URLs since it'd probably lead to impersonations trying to scam out of money or games and would lead to a lot of complaints.

They also have a bunch of other features, but I really don't care about those.

Let's do something about it

It's a given that to do this, you probably already have your own domain name to make the necessary changes, and that you already have some experience altering DNS records for your site.

Subdomain setup

First of all, we need to set an A record in order to point the new subdomain towards our IP. My VPS comes with an IPv6 address, so I'll also set an AAAA record for that too. This is the easy part:

It's as simple as that, really. (A table of DNS records)

So, now the above records means that discord.chaoticlaw.com now points to my VPS IP. With that done, let's move on to allocating a Virtual Host.

Virtual Hosts

In NGINX, you can designate hosts by writing out a server block in a configuration file with server_name.

server_name: discord.chaoticlaw.com

Basically, when your web browser attempts to navigate to a site, it sends the host name it's looking for in the request. With this, NGINX will run with the configuration if there's a matching server_name.

Then, we set up the rest of the configuration file:

server {

  listen 80;
  # Listen on IPv6
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  # Our server name to look out for
  server_name: discord.chaoticlaw.com;

  # ... Some SSL/TLS stuff happens here

  # Where we'll put our HTML for this subdomain
  root /var/www/html/discord/;
  index index.html index.htm;

  # Cache some common media formats so the user doesn't have to download it every time
  location ~* \.(jpg|jpeg|svg|js|png|ico)$ {
    expires 30d;

  # Finally redirect to HTTPS if a visitor attempts to visit on HTTP
  location / {
    if ($scheme != "https") {
      return 301 https://$host$request_uri;


After validating that this configuration works out (using nginx -t), we can reload the NGINX service by restarting it (sudo service nginx restart).

Then after that, I spent some time composing the page to make it look nice and fitting with my brand. Because I own the content and the gateway, it's only appropriate that I customise it to my liking. The features I've included are:

  • A button which links to the custom invite URL given to me by Discord
  • Custom background, embedded into the page and loaded with a blur effect
  • Custom content (I ended up listing the rules and their associated penalties)

With that all done and uploaded, you can see the result here!

Chaotic Law

Chaotic Law

Web designer in training, LP maker and game streamer! Not a maker of games though.

Read More
Setting aside a subdomain for my Discord Server
Share this

Subscribe to Chaotic Law