How to upload a file via POST and with auth

1. Caddy version (caddy version): v2.3.0

2. How I run Caddy:

I run caddy inside docker on Ubuntu vbox, via docker-compose, using a Caddyfile.

a. System environment:

Ubuntu 18.04 LTS
Docker version 19.03.11
docker-compose version 1.23.0-rc3

b. Command:

Start caddy at localhost

docker-compose up

c. compose file:

version: "3.7"
services:
  caddy:
    image: caddy:2
    container_name: caddytest
    ports:
      - 8051:80
      - 4431:2015
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./data:/var/www/cdn

d. My complete Caddyfile:

:80

root * /var/www/cdn

# Serve everything else from the file system
file_server browse

@postupload {
  method POST
}
basicauth @postupload {
  jenkins JDJhJsdaffdsafdsfasdsdfdfETjY0RERGLk1nLzQvZkc2
}

3. The problem I’m having:

I want to serve my app installers from a custom server for what I want to use caddy.
Browsing the files and downloading works.
Now I want to upload new installers from CI jenkins and I try to figure out the correct curl command, to put a file “installer.msi” into directory “/appname/Major/Major.Minor/installer.msi”. This upload shall be secured with basic auth. The basic auth seems to work but the file upload doesn’t, because I had to guess a command (any links to the documentation? Did not find it).

4. Error messages and/or full log output:

There are no error messages.

5. What I already tried:

`curl -X POST -u "jenkins:password" -F "fileobj=@installer.msi" http://localhost:8051/

6. Links to relevant resources:

https://caddyserver.com/docs/caddyfile/directives/file_server

image

1 Like

Caddy’s file server doesn’t support file uploads. If you want to upload files, you’ll need to use another tool (and you can put Caddy as a proxy in front of it).

You can consider using the Filebrowser project which does support file uploads:

This topic was automatically closed after 30 days. New replies are no longer allowed.