Caddy and Django


(carebear) #1

I’m trying to get Caddy to use my Django project. Even finding documentation for Caddy with Python is difficult to find.
I haven’t tried anything so far


(Matt Holt) #2

Try the example: https://github.com/caddyserver/examples/tree/master/django - this repo is even linked to by the Caddy docs.


(carebear) #3

Wow it Matt himself. Seen part of your video in Caddy. I really enjoyed your presentation skills. You were a great speaker!

But yeah, I’m not sure how to do steps 3 and 4 on the example and I’m not sure what project.wsgi is.


(Matthew Fay) #4

Step 3 is proxying from Caddy to gunicorn. From the gunicorn docs:

-b BIND, --bind=BIND - Specify a server socket to bind.

So we know based on the example gunicorn command that it’s listening on port :8000 on the address 127.0.0.1. We’ll need to proxy to it - check out the usage of the proxy directive in the example Caddyfile at https://github.com/caddyserver/examples/blob/master/django/Caddyfile.

If your setup is more complex than that you’ll need to modify that appropriately, as well as the gunicorn launch.

project.wsgi is Django’s default output; check out the docs here: https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/

There’s even some gunicorn-specific deployment documentation for Django here: https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/gunicorn/

If you follow that, the rest is simply putting Caddy in front and proxying everything back.

I have to admit I’m confused by step 4 as well. I’d read “statics and medias” as images, CSS, JS, video, etc; with all requests going to gunicorn, though, I’d expect it to be handled there (it’s not like Caddy will serve anything on this site label anyway, with the proxy / sending everything upstream).


(system) #5

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.