How to change WordPress UPLOAD only URL to a subdomain to bypass CDN file size restrictions
we run a large format printing business at posterprintshop.com that routinely gets very large file uploads through our various upload methods on the site (mostly HTTP POST/UPLOAD) as customers need to be able to easily upload through their browser.
A typical page where customers upload at is at http://posterprintshop.com/order-wizard
File uploads are routinely over 100MB because we need high resolution files for printing. This is not an issue normally as our post max and PHP upload limits are set high at 500MB.
The issue is that we’d like to put our site behind a CDN, specifically StackPath. When you do this, the DNS of main URL will now point to StackPath and they will ‘sit between’ the uploads and downloads to the site. Unfortunately, they have a hard restriction file size limit of 100MB and they drop or deny any file size upload over this. No negotiation on changing this.
Various searches give ideas on how to bypass this by setting up a subdomain to receive the file upload, this bypasses the CDN as the subdomain DNS will still point directly to our server and not to the CDN.
There is even a similar topic about this here:
Change WordPress' media upload URL?
However, that solution isn’t working for us. We’re still getting a 413 error (failed to load resource) on uploads over 100 MB. So somehow StackPath CDN is still intercepting. The particular error seems to be coming from "admin-ajax.php" in the console.
I think the above post is in the right direction, but out dated.
So, I’m looking for help on how to intercept/redirect (or whatever we would call it), anything in WordPress plugins or core that are calling and handling the upload (uploads only) to come from "http://up.posterprintshop.com" instead of the main domain of the site, so that it will bypass the CDN limitation. ie: how can we ensure that any GET/POST/UPLOAD request by any function in WordPress is being re-written to be called from "up.posterprintshop.com" while rest of site comes from regular domain. Then only these upload requests and functions will not be going through StackPath and should, theoretically, work for large files as StackPath CDN won’t be intercepting the request.
Thank you for any help on this!
Leave an answer