Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse error after bumping #288

Closed
tetra12 opened this issue Feb 21, 2024 · 6 comments
Closed

parse error after bumping #288

tetra12 opened this issue Feb 21, 2024 · 6 comments

Comments

@tetra12
Copy link

tetra12 commented Feb 21, 2024

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
Copy link
Contributor

elee1766 commented Feb 25, 2024

hi this is probably my fault.

if you're building against the master branch of caddy, it has this merged in caddyserver/caddy#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
Copy link
Author

tetra12 commented Feb 25, 2024

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
Copy link
Contributor

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
Copy link
Author

tetra12 commented Feb 26, 2024

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
Copy link
Contributor

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
Copy link
Author

tetra12 commented Feb 26, 2024

@elee1766 Thanks for your help, I appreciate. That was a great catch 👍 and I had name miscompare in my Caddyfile 😆

@tetra12 tetra12 closed this as completed Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants