We're very nearly done deploying our Django app. There's just one more thing we should take care of. Having a raw IP as our website address is kind of yucky, isn't it? You're not going to ask your friend, boss, or mum to visit 184.108.40.206 to check out your cool new Django app. You want a domain name like mycoolwebsite.xyz! Let's finish up our deployment by setting up a domain for our web app.
Here we will learn how to:
A quick note before we start - usually you would do this at the start of the process, right after you create your server, because setting domain name records can take a long time. The reason we're doing it last in this guide is to make sure that you're confident that your app is working before we start fiddling with DNS. If you've never heard of DNS before, I did a short blog post that explains the basics.
If you already own a domain name for your app your can skip this step. To get a domain name we need to give someone some money. We're going to go to Namecheap and buy a domain name. Why Namecheap? Domain name registrars exist to sell domains and occasionally fuck you over by raising prices and trying to sell you crap that you don't need. They're generally a pain, so I did a Google search for "site:reddit.com best domain seller", and the good people of Reddit seemed to hate Namecheap the least.
We're going to use Cloudflare to set up our DNS records. I've written elsewhere on why I like Cloudflare. TLDR it's pretty easy to use and provides some nice bonus features like caching your static files, SSL encryption and analytics.
All requests to our domain (mycoolwebsite.xyz) are going to pass through Cloudflare's servers, which are running NGINX under the hood. This kind of set up is called a "reverse proxy", because we have a "proxy" (Cloudflare), routing all incoming traffic to our server. This is in contrast to a "forward proxy", which deals will outbound traffic.
... 30 minutes later ...
Alright! We're done! Congratulations, you've deployed a Django app. Just as a quick recap, you've learned how to:
Now I encourage you to take the things you've learned and write your own Django app and try deploying that. It will probably break at some point, it always does, but I hope you're able to use the skills that you've picked up in this guide to debug the problem and fix it.
You've got the basics down, but there is a lot of stuff you can learn about deploying Django and web apps in general. Some things you might want to look into at some point:
There's an endless list of stuff you can learn, and there's no need to do it all right now, but it's there if you're interested.
If you have any feedback on this guide, or questions about the steps, you can email me at [email protected]
If you have any feedback or questions email me at [email protected]