Caddy/Django problem

I am having a problem getting Caddy v2 to run with Django. It seems like the PROXY command is causing problems. I will provide a working example of my Caddy file and the non working version below … one with PROXY and one WITHOUT.

Working Caddyfile version (WITHOUT PROXY)
root * /home/myuser/my-project/frontend/build

Problem Caddyfile version (WITH PROXY) {
root /home/myuser/my-project/frontend/build
proxy / localhost:8000 {

Obviously, for Caddy to work in my scenario, I need to be able to use PROXY. I have scoured Google looking for solutions and I have mirrored exactly what I did above, and it doesn’t work at all. Caddy will not start. Please help. I am about to switch to another HTTP server. I really like CADDY but complete documentation seems to be elusive.


Hi Jeff,

Thanks for using Caddy 2 while it’s still in beta!

Have you seen Home · caddyserver/caddy Wiki · GitHub? As far as I know it has everything up-to-date. I know a wall of text isn’t awesome, but the table of contents and Find In Page can help. I’m working on new docs for the next few weeks, so look forward to that.

What error are you getting?

The transparent subdirective isn’t a thing in v2, you will probably want to remove it.

So I removed the transparent and it is still failing with an error. Am I messing up the syntax somehow? This is all I have in my Caddyfile: {
root /home/kindreduser/kindred-project/frontend/build
proxy / localhost:8000

Let me know your thoughts. I have read through the documentation pretty thoroughly with regards to the Proxy command and did a lot of searching on the internet. It looks like my syntax is correct. I will upload the error.

My goal is to get a React + Django App to production on DigitalOcean with Caddy and Gunicorn. It works great displaying the React app login screen with SSL. The problem I am having is with the PROXY to get to the Django REST environment.

What’s the error though? “Failed” isn’t exactly an error message :slight_smile:

I attached the message above in an attachment. That is all I receive.

So thoughts on the generic error? Does my code appear to be correct?

I think you may need to check the systemd service’s logs to get the actual error.

One option would be to use Caddy v1 while v2 and its documentation are in beta.

Can anyone tell me if the code is correct using Caddy v2? It is obviously a syntax problem that Caddy doesn’t like since when I remove the PROXY block, it works fine. How do I proxy to Django in Caddy v2? I cannot find any examples anywhere with Django in Caddy v2 documentation.

The version you’ve posted with the proxy directive included is v1 syntax.

Double check the v2 syntax, noting in particular that in v2 proxying is achieved with the reverse_proxy directive.

Home · caddyserver/caddy Wiki · GitHub
Home · caddyserver/caddy Wiki · GitHub

P.S. For future reference, the screenshot showing your Caddy service status unfortunately does not give us much in the way of useful information (it only shows that the service has stopped because Caddy exited).

Caddy always outputs information when it exits, systemd keeps these logs, and you can use journalctl -b -u caddy to see all of Caddy’s output since the server last booted up.

It’s not necessary right now because this is clearly just a syntax issue, but it will help if you run into any problems in future.

So, I got the server to start using the correct reverse proxy and now when I browse to the site, the site is blank … like it isn’t even recognizing the index.html file. No errors. No logs. No idea why it would be doing this. I have cleared the browser cache. Any ideas from anyone? Searching the forum, apparently this has not happened to anyone else?

Is there a path to go back to Caddy v1.0? I don’t think v2 is near ready for primetime. Do I just have to remove Caddy v2 and start completely from scratch??

Is there any sort of documentation that tells me how to remove Caddy from Ubuntu 18.04?

Here is my Caddyfile. It doesn’t get more basic than this. Not sure what I am doing wrong here.Caddyfile2

Hi @jeffhatton, one more thing you’ve got to do in v2 is tell Caddy you want it to act as a file server.

In v1 this was assumed in all cases and couldn’t be disabled.

Basically, just add the file_server directive in v2.

Home · caddyserver/caddy Wiki · GitHub

(Apologies - I would’ve mentioned this earlier, except your example (proxy /) covered the entire site and would’ve made a file server redundant, but that’s not the case if you’re only proxying out of a subfolder and serving the rest off the web root.)

1 Like

Where I love the idea of Caddy and think it has potential, there are simply too many holes in the documentation currently and not enough people using it to figure out problems via the internet. At 2 am when there is a problem like I had with file_server not enabled and wasn’t included in the documentation and there is no way for me to figure that out on my own … that presents a real bad problem. Most people aren’t answering my questions at 2am on the forum. I understand I am using a beta product and don’t want to be too harsh. Therefore, I am going back to Nginx until you go live with version 2 and get the appropriate documentation out there (deprecated syntax from v1, differences between v1 and v2, etc.).
There are just a lot more Nginx users and a lot of problems that I encounter, someone already has in most cases. I am sure I will try Caddy again at some point. I hope you leave this post out there for someone who may be experiencing the same issue I was having. Thanks for your help.

file_server is documented.

Home · caddyserver/caddy Wiki · GitHub

We appreciate you trying out the v2 beta. I’m sorry to hear that after helping clarify and resolve these issues, you’re looking to move away.

A valid point, although I think that the quality of the free support here compares incredibly well to giants like nginx and Apache, especially given the disparity in “market share” (for lack of a better phrase). If you’re running something business critical, and need fast, comprehensive support from the developers themselves - that’s an option, too.

Being harsh isn’t necessarily bad, either - harsh critique results in a better program, and the developers want v2 to be great.

Aye, that’s the goal. Lots of the posts and issues we’ve experienced and resolved on these forums have become top Google results for people running into the same problems. v2 is pretty new, so we don’t quite have that quantity of historical solutions available to search for.

To follow up on these, you can simply delete the Caddy binary (which caddy), along with any v2 configuration you may have placed on your system. Then, if you like, you can reinstall Caddy v1 - or as you’ve indicated, go back to nginx.


The new documentation site is up: Welcome — Caddy Documentation

Still a WIP. The v2 Caddyfile will probably be the last thing added because it is still rapidly changing in the beta.

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