lindenlab / caddy-s3-proxy

s3 proxy plugin for caddy
Apache License 2.0
72 stars 22 forks source link

When refreshing the homepage, if the client carries "If Modified -", a 403 error will be triggered #63

Open tossp opened 1 year ago

tossp commented 1 year ago
Aug 02 15:34:06 mc-tx caddy[2432909]: {"level":"debug","ts":1690961646.5239983,"logger":"http.handlers.s3proxy","msg":"get from S3","bucket":"static","key":"/wx_sj9_web/index.html"}
Aug 02 15:34:06 mc-tx caddy[2432909]: {"level":"debug","ts":1690961646.5725636,"logger":"http.log.error","msg":"can not view a directory","request":{"remote_ip":"118.x.x.x","remote_port":"62536","proto":"HTTP/3.0","method":"GET","host":"swxb.xxx","uri":"/","headers":{"Sec-Fetch-Mode":["navigate"],"Sec-Ch-Ua-Mobile":["?0"],"Upgrade-Insecure-Requests":["1"],"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br"],"If-Modified-Since":["Wed, 02 Aug 2023 07:27:02 GMT"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Fetch-Site":["none"],"Sec-Fetch-User":["?1"],"If-None-Match":["\"bdfba442eeb67438a552cbdf0a2fa8dd\""],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"],"Sec-Ch-Ua":["\"Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"115\", \"Chromium\";v=\"115\""],"Dnt":["1"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"],"Accept-Language":["zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"],"Cache-Control":["max-age=0"]},"tls":{"resumed":true,"version":772,"cipher_suite":4865,"proto":"h3","server_name":"swxb.xxx"}},"duration":0.048614851,"status":403,"err_id":"x31z70mb4","err_trace":"caddy-s3-proxy.S3Proxy.GetHandler (s3proxy.go:479)"}
tandav commented 3 months ago

Same here, issue still exists. Here's a workaround that fixes it by deleting the headers from the request:

s3.example.com {
    request_header -If-Modified-Since
    request_header -If-None-Match
    route {
        s3proxy {
            endpoint http://localhost:9000/
            region dummy
            bucket files
            force_path_style
        }
    }
}