Hi Wim,
Just a quick one - we've got a bit of a complex setup, using squid to proxy our main server on another continent. We have two top level domains:
www.example.co.uk (UK server)
www.example.com (US and RoW - squid server)
We've set up CNAME DNS records for *.cdn.example.co.uk and *.cdn.example.com; I need to set CDN up in origin pull mode to grab resources not only from a particular hostname, but also from the right TLD. So for example:
0.cdn.example.co.uk| .jpg (IF ON THE UK SITE)
0.cdn.example.com| .jpg (IF ON THE US/RoW SITE)
I'm assuming I need to use the cdn_pick_server() function to use the right top level domain - but cannot figure out for the life of me how.
Any hints?
Any help hugely appreciated!!
Many thanks,
Jack.
Comments
Comment #1
wim leersHow about this: define the variable that sets this (
cdn_basic_mapping) in your settings.php file, create sites/example.co.uk/settings.php and sites/example.com/settings.php, and there you go! :)Comment #2
essenceofginger commentedHi Wim, thanks for the reply.
Perhaps I didn't explain very well. There is only one sites/[sitename] folder as the .com is an exact mirror of the .co.uk - using squid proxy.
I thought about possibly using PHP to grab the hostname, and inserting that into the server array... but that said, I can't figure out for the life of me how to edit the server array anyway.
:(
Comment #3
essenceofginger commentedJust to clarify - content translations (with entity translation module) are served based on URL detection, in this case.
Comment #4
wim leersIf it's a squid proxy serving the *exact* same content for both the .com and the .co.uk, then how are you serving domain-specific content? It seems you're not; the sites appear to be identical, both simply serve /en-uk and /en-us content?
Comment #5
essenceofginger commentedBy using entity translation and locale. If the .com is detected in the request, then it serves up the US translation of the node instead of the UK. So yes, you're right, one serves /en and the other serves /en-us.
Here's an actual example:
http://www.brightpearl.co.uk/about-the-app/stock-control (here on in 'UK')
http://www.brightpearl.com/about-the-app/inventory (here on in 'US')
Notice the node ID attached as a class to the body tag. So as far as using the CDN module is concerned (this is only in testing mode by the way, so you'll have to take my word for it), this is how the masthead image is rewritten:
On the UK site:
http://3.cdn.brightpearl.co.uk/cdn/farfuture/dCjjDWU0EW3D2KKJ6swPAKSNZqB...
on the US site:
http://3.cdn.brightpearl.co.uk/cdn/farfuture/dCjjDWU0EW3D2KKJ6swPAKSNZqBnYc3Wyu6FsEzoeBY/mtime:1331086977/sites/default/files/masthead_productsandstock.jpg
Here's the CDN mapping from admin/config/development/cdn/details:
http://3.cdn.brightpearl.co.uk| .jpg .jpeg .png
So, as you can see, the .com site needs pull from 3.cdn.brightpearl.com, otherwise US visitors are grabbing content via a transatlantic hop. It's almost like i need to be able to specify that the CDN mapping is language specific (EN), and then create an EN-US alternative.
I can't get my head around this! Top notch module, by the way - it's made serving our content up by CDN so much easier. Hooking into the URL detection of the Locale module is the last piece of the puzzle.
Comment #6
essenceofginger commentedHey Wim,
In case you or anyone else finds this useful, we got it working by adding some extra code into the body of cdn_pick_server(). Obviously in this instance it's only useful if you've got a .co.uk and a .com, but could be easily rewritten to add more.
Comment #7
wim leersThanks! Documented now for future reference!
D7: http://drupalcode.org/project/cdn.git/commit/24282dd
D6: http://drupalcode.org/project/cdn.git/commit/8dcd87e
Comment #8.0
(not verified) commentedtypo correction