Confgure HA proxy as a reverse proxy for AWS S3 stati files

Hello Guys ,
I need some help with this , scenario , I need the web clients to reach my s3 bucket for static files through HA Proxy , current haproxy.cfg configuration is as below

frontend http
bind *:443 ssl crt /etc/ssl/certs/haproxy.pem
default_backend webapps
option forwardfor
backend webapps
balance roundrobin
server server1 s3-r-w.ap-south-1.amazonaws.com:443 sni str(bucket_name.s3.ap-south-1.amazonaws.com)

HA proxy should do the below URL rewriting at the proxy (at the backend)
https://www.test.com/path/pathtofile ==> https://www.s3.amazon.com/path/pathtofile
any help is highly appreciated

thanks

Hi, This worked for me:

frontend  main
    bind *:80

    default_backend s3

backend s3
    http-request set-header host _bucket_name_.s3.eu-central-1.amazonaws.com
    http-request del-header authorization
    http-response del-header x-amz-id-2
    http-response del-header x-amz-request-id

    server s3 _bucket_name_.s3.eu-central-1.amazonaws.com:80

Please note I was using S3 virtual address of bucket.

HA proxy should do the below URL rewriting at the proxy (at the backend)

You don’t need to do any rewrite because HaProxy works as proxy in this case.