Downloadable products on Apache server with Nginx reverse proxy
-
I am trying to make a woocommerce website where I have downloadable products (which can be large in size). My host is siteground.com. Siteground runs an Apache server with Nginx reverse proxy acting as a cacher. Because of the large size of the files, I want to use X-sendfile/X-Accel-Redirect for file delivery and not ForceDownload. Redirect is not an option because of lack of security.
I have confirmed with siteground that mod_xsendfile is not installed and will not be installed so just setting woocommerce settings to use X-sendfile would failover to ForceDownload based on the logs which is not great given the large file sizes. However, siteground support suggested that because of the Nginx proxy, X-Accel-Redirect might achieve the same result. I modified the code in woocommerce/includes/class-wc-download-handler.php to explicitly use X-Accel-Redirect (despite the server being Apache) and I can confirm that this does in fact deliver the files but ONLY if I also modify the .htaccess file in the wp-content/uploads/woocommerce_uploads to allow all request which obviously defeats the purpose of having secure downloads (anyone can just access the files as long as they know the address). If the .htaccess file is left to the default of “deny from all” I will get a 403 error using X-Accel-Redirect.
Can anyone with knowledge of siteground in particular or reverse proxies in general tell me whether I can modify the .htaccess file in such a way to allow X-Accel-Redirect delivery while not allowing direct access to the files?
- The topic ‘Downloadable products on Apache server with Nginx reverse proxy’ is closed to new replies.