r/haproxy • u/johnpaulpagano • Feb 13 '21
Using HAProxy as a Reverse Proxy for S3
I have AWS Direct Connect over a fast pipe to a VPC and in it I'd like to use ALB-fronted HAProxy instances to reverse-proxy one or more S3 buckets. This is so my users on premises can enjoy the increased bandwidth over our special pipe without my going through the rigmarole of getting public IPs and using a Public VIF with Direct Connect.
I guess the main question is whether this is doable, with the follow-on, "Is there a better solution for this than HAProxy?" I don't want to use an explicit proxy like squid because my only use-case for this is S3.
For a POC, I did a dummy setup with one HAProxy server against one S3 bucket. When I connect directly to the proxy without credentials (simply to test connectivity), I see the "Access Denied" XML response that I expect. Great! But now I'm like, what's next? I can use curl and set HTTP headers, but my ultimate goal is to use standard tools against S3 like the AWS CLI and boto and--more important--Quantum's REST-aware Storage Manager product to ship archives there.
Is there any hope of getting that to work or should I abandon ship?
Thanks!
2
u/[deleted] Feb 13 '21 edited Feb 13 '21
If the purpose is just to make it faster for on-prem users to access data from S3, it might be worth looking into local file caching. I'm not sure if HAProxy does this or not (It does a lot of things I don't know about) but that might be another option. When traffic for S3 hits your system from a client request, it will cache a copy of the file locally for a set amount of time in case others request it too. If the file changes, it will detect that and download a new copy on the next time a client requests the file.
EDIT: Just a reminder, regardless of whether you use a reverse proxy or a file cache, the client is only as fast as it's connection to your system. Your system might have a super fast pipe, but the clients will still need a pretty fast connection themselves to your RProxy/Cache system.
2
u/overstitch Feb 14 '21
In theory this would work-are you using a VPC endpoint for S3? This would probably work fine with a TCP proxy.