Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Hosting a Django app with Caddy and PostgreSQL: Difference between revisions

From Nest Guides
Twonum (talk | contribs)
No edit summary
Twonum (talk | contribs)
No edit summary
Line 1: Line 1:
THIS IS A WIP!
THIS IS A WIP!


This (unofficial) guide was made by [@twonum https://hackclub.slack.com/team/U094NTBR1S5] (feel free to ask me for help).
This (unofficial) guide was made by [https://hackclub.slack.com/team/U094NTBR1S5 @twonum] (feel free to ask me for help).


I'm using Hypercorn as it's an ASGI server (for WebSockets support). To use a different server, replace the <code>hypercorn</code> commands with the ones that your server uses.
I'm using Hypercorn as it's an ASGI server (for WebSockets support). To use a different server, replace the <code>hypercorn</code> commands with the ones that your server uses.

Revision as of 14:52, 15 July 2025

THIS IS A WIP!

This (unofficial) guide was made by @twonum (feel free to ask me for help).

I'm using Hypercorn as it's an ASGI server (for WebSockets support). To use a different server, replace the hypercorn commands with the ones that your server uses.

Tools this guide uses
  • Hypercorn ASGI server
  • Caddy reverse proxy and web server with automatic HTTPS
  • PostgreSQL relational database for Django's ORM
  • systemd "daemon" (as it's called in Unix) to manage services


I'll assume that orpheus is your username and this is your directory structure:

  • ~ (/home/orpheus)
    • project
      • manage.py
      • ...
    • static
      • project
        • static
        • media
    • Caddyfile
    • .config
    • ...

Getting ready

First, get a shell to Nest. Don't have a Nest account?

ssh orpheus@hackclub.app

Get Nest resources

ssh orpheus@hackclub.app
export PROJECT_NAME="your project directory name" # set this to your project's directory name (like "project" in <code>/home/$USERNAME/project</code>)

hackclub.app or custom domain?

$PROJECT_NAME.$USERNAME.hackclub.app (free)

export PROJECT_DOMAIN=$PROJECT_NAME.$USERNAME.hackclub.app
nest caddy add $PROJECT_DOMAIN

Custom domain (looks better, but you need your own DNS)

Add a CNAME record to $USERNAME.hackclub.app. If you use Cloudflare or another proxy, turn the proxy off. Wait and run this to check your DNS record:

export PROJECT_DOMAIN="hello.example.com" # set this
dig $PROJECT_DOMAIN CNAME

Then:

nest caddy add $PROJECT_DOMAIN

Get your project's files on Nest

Copy the directory containing manage.py to /home/$USERNAME/$PROJECT_NAME. See Quickstart#Using_the_Account.

cd ~/$PROJECT_NAME