HTTP POST to Node Red through Caddy

1. Output of caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I run Caddy:

a. System environment:

Ubuntu Linux 20.04.5

b. Command:

Paste command here.

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane. -->

d. My complete Caddy config:

My Caddyfile :
myname.com {
	 reverse_proxy localhost:10000
}

red.myname.com {
	reverse_proxy localhost:1880
}

grafana.myname.com {
	reverse_proxy localhost:3000
}

db.myname.com{
	reverse_proxy localhost:8086
}

3. The problem I’m having:

  • I have a VM in the cloud running Node Red and Caddy.
  • Caddy works perfectly for the web interface.
  • I have a node listening for HTTP POST attempts.
  • The address for the Node Red site is red.myname.com
  • The Node Red is listing on /upload
  • I want to use HTTP POST to upload a file to Node Red
  • When posting to this site I am getting a HTTP Response code 308 (Permanent Redirect).
  • The data is not showing up in Node Red.

I have set up an identical Node Red instance locally and the HTTP POST works correctly. This shows that the reason for the failure is my inability to configure Caddy correctly.

I have a very basic configuration using the Caddyfile which works fine for the Node Red web interface (and Webmin) so it looks like Caddy is working correctly, I just need to update the configuration to accept the HTTP POST.

4. Error messages and/or full log output:

Paste logs/commands/output here.
USE THE PREVIEW PANE TO MAKE SURE IT LOOKS NICELY FORMATTED.

5. What I already tried:

I have read through the documentation and I have tried added the POST option to my Caddy file, like this:

red.myname.com {
@post method POST
reverse_proxy @post localhost:1880
}

To be honest, I’m unsure what this actually does or how it works, but it did not resolve the issue and broke access to the web interface.

I am using ARC on my PC to test the connection.

Any help to get this working would be much appreciated. I feel there is something simple and obvious which I am missing!

Please let me know if I have missed any useful information.

6. Links to relevant resources:

Yeah all this would do is prevent any other method than POST from being passed to your proxy. That’s definitely not what you want.

There’s not enough in your post to know the problem. We need to see your logs for Caddy, which you didn’t provide.

You might be making an HTTP request instead of HTTPS, which would respond with an HTTP->HTTPS redirect. Make sure to use https:// with whatever you’re using to connect.

1 Like

Hello,

Thank you very much for your reply. I’m new to this and really needed help to resolve this issue.

You were absolutely right. I was making a http request as I (incorrectly) assumed that all calls to Caddy should be http and it would automatically convert it to https.

I am delighted I can now connect to my server in the cloud.

Thanks again for your help and hard work!

2 Likes

That’s not how it works – if you make an HTTP request, Caddy will respond with a redirect, telling the client “try again, but with HTTPS please”. Browsers will follow the redirect and make it look transparent. But for other clients that don’t follow redirects, you must start with https:// from the start.

2 Likes

Ah, I understand now. Thank you for taking the time to follow up with an explanation.

Every day is a school day!

2 Likes