sagikazarmark / caddy-fs-s3

Caddy FS module for AWS S3
MIT License
47 stars 2 forks source link

parse error after bumping #288

Closed tetra12 closed 4 months ago

tetra12 commented 5 months ago

Hello I've been using this module for months, but it now fails to parse my Caddyfile.

http://example.com {
  file_server {
    fs s3 {
      bucket "some-docs-tvh8rz"
      region "my-region"
      endpoint "http://<IP>"
      use_path_style
    }
  }
}

Error: adapting config using caddyfile: parsing caddyfile tokens for 'file_server': unknown subdirective '{', at Caddyfile:103

I'm building a custom Caddy binary with your module included. Caddy version: v2.7.6 master Module version: v0.3.1

elee1766 commented 4 months ago

hi this is probably my fault.

if you're building against the master branch of caddy, it has this merged in https://github.com/caddyserver/caddy/pull/5833

i believe you need to change your config to:

{
 filesystem my-s3-fs s3 {
      bucket "some-docs-tvh8rz"
      region "my-region"
      endpoint "http://<IP>"
      use_path_style
    }
}
http://example.com {
  file_server {
    fs my-s3-fs

    /// ... your config
  }
}
tetra12 commented 4 months ago

Thanks for your response. Indeed your fix helped me to successfully validate my Caddyfile. However, I'm getting 404 with the following:

Feb 25 10:57:42 hyp0 caddy[715491]: {"level":"debug","ts":1708858662.370997,"logger":"http.log.error","msg":"filesystem not found","request":{"remote_ip":"xxxx","remote_port":"3006","client_ip":"xxxxx","proto":"HTTP/1.1","method":"GET","host":"my-host","uri":"/","headers":{"User-Agent":["HTTPie/2.6.0"],"Accept-Encoding":["gzip, deflate, br"],"Accept":["*/*"],"Connection":["keep-alive"]}},"duration":0.000084627,"status":404,"err_id":"99r27zn28","err_trace":"fileserver.(*FileServer).ServeHTTP (staticfiles.go:258)"}

Feb 25 10:57:42 hyp0 caddy[715491]: {"level":"error","ts":1708858662.3710463,"logger":"http.log.access","msg":"handled request","request":{"remote_ip":"xxxx","remote_port":"3006","client_ip":"xxxx","proto":"HTTP/1.1","method":"GET","host":"my-host","uri":"/","headers":{"User-Agent":["HTTPie/2.6.0"],"Accept-Encoding":["gzip, deflate, br"],"Accept":["*/*"],"Connection":["keep-alive"]}},"bytes_read":0,"user_id":"","duration":0.000084627,"size":0,"status":404,"resp_headers":{"Server":["Caddy"]}}

my setup is the following:

{
  admin off
  filesystem my-fs-s3 s3 {
    bucket "docs-tvh8rz"
    region "reg-0"
    endpoint "http://192.168.1.100:9000" // localhost
    use_path_style
  }
}
http://example.com {
  file_server {
    fs my-s3-fs
  }
}

PS: I have a full access on the bucket docs-tvf8rz and can read/write it with the minio client

elee1766 commented 4 months ago

Thanks for your response. Indeed your fix helped me to successfully validate my Caddyfile. However, I'm getting 404 with the following:

Feb 25 10:57:42 hyp0 caddy[715491]: {"level":"debug","ts":1708858662.370997,"logger":"http.log.error","msg":"filesystem not found","request":{"remote_ip":"xxxx","remote_port":"3006","client_ip":"xxxxx","proto":"HTTP/1.1","method":"GET","host":"my-host","uri":"/","headers":{"User-Agent":["HTTPie/2.6.0"],"Accept-Encoding":["gzip, deflate, br"],"Accept":["*/*"],"Connection":["keep-alive"]}},"duration":0.000084627,"status":404,"err_id":"99r27zn28","err_trace":"fileserver.(*FileServer).ServeHTTP (staticfiles.go:258)"}

Feb 25 10:57:42 hyp0 caddy[715491]: {"level":"error","ts":1708858662.3710463,"logger":"http.log.access","msg":"handled request","request":{"remote_ip":"xxxx","remote_port":"3006","client_ip":"xxxx","proto":"HTTP/1.1","method":"GET","host":"my-host","uri":"/","headers":{"User-Agent":["HTTPie/2.6.0"],"Accept-Encoding":["gzip, deflate, br"],"Accept":["*/*"],"Connection":["keep-alive"]}},"bytes_read":0,"user_id":"","duration":0.000084627,"size":0,"status":404,"resp_headers":{"Server":["Caddy"]}}

my setup is the following:

{
  admin off
  filesystem my-fs-s3 s3 {
    bucket "docs-tvh8rz"
    region "reg-0"
    endpoint "http://192.168.1.100:9000" // localhost
    use_path_style
  }
}
http://example.com {
  file_server {
    fs my-s3-fs
  }
}

PS: I have a full access on the bucket docs-tvf8rz and can read/write it with the minio client

this might be a change in how basepath is handled

what's the general directory structure of your s3 buckets and how are you trying to access such files?

tetra12 commented 4 months ago

what's the general directory structure of your s3 buckets and how are you trying to access such files?

Did you reproduce my report? Its simple. All you need is to check out caddy and build your module along with it. See here

how to access my file:

echo "Hello World" > index.html
mmc cp index.html s3/docs-tvf8rz

I use env to store by api keys and run caddy with the environment

elee1766 commented 4 months ago

what's the general directory structure of your s3 buckets and how are you trying to access such files?

Did you reproduce my report? Its simple. All you need is to check out caddy and build your module along with it. See here

how to access my file:

echo "Hello World" > index.html
mmc cp index.html s3/docs-tvf8rz

I use env to store by api keys and run caddy with the environment

sorry, this is not my module. i am just trying to help as i made the underlying change to caddy. I don't have this repo cloned...

anyways, there's a typo in your config:

{
  admin off
  filesystem my-fs-s3 <--------- here s3 {
    bucket "docs-tvh8rz"
    region "reg-0"
    endpoint "http://192.168.1.100:9000" // localhost
    use_path_style
  }
}
http://example.com {
  file_server {
    fs my-s3-fs <----- here
  }
}

those two strings should match. you have my-fs-s3 at the top but my-s3-fs at the bottom.

tetra12 commented 4 months ago

@elee1766 Thanks for your help, I appreciate. That was a great catch :+1: and I had name miscompare in my Caddyfile :laughing: