Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 06, 2017 @ 08:03
    Ismail Mayat
    0

    Imagegen in load balanced environment

    Hello,

    I am using imagegen 2.9.1 with umbraco 6.1.6. All is working well. However I need to move to load balanced setup. I have 2 servers in my cluster shared db and the media folder is setup as virtual directory. The imagegen cache folders are not shared and are not replicating so each server manages its own cache folder.

    When I try to request images via imagegen i get broken images. In the imagegen config I have added ips of both servers and they can talk to each other. So im xml config I have,

    <RemoteDomainWhiteList><Domain>10.1.2.176</Domain<Domain>10.1.2.177</Domain</RemoteDomainWhiteList>
    

    I have updated ips in the post as i do not want to divulge sensitive data. Am i right in assuming I only need one domain entry and that is wildcard of the site url?

    Regards

    Ismail

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Sep 06, 2017 @ 08:43
    Douglas Robar
    0

    Hi, Ismail,

    On the whole, that sounds correct. You've understood that each server is responsible for its own ImageGen cache so you can't replicate the 'cached' folders.

    Time for a bit of debugging to rule out anything obvious. Most importantly, that you're running in Professional mode properly.

    ImageGen not in Professional mode

    ImageGen is always in 'Professional' mode when running on localhost or any *.local domain to allow you to test out the Pro features before purchasing a domain key.

    You can check if ImageGen is running in Professional mode with the URL http://example.com/imagegen.ashx?version (where you'd type your actual domain in place of 'example.com').

    If the version check displays 'ImageGen Basic' at the top rather than 'ImageGen Professional' please check these items which should resolve most situations:

    Your site's /web.config file should have two entries for ImageGen in addition to your other site settings, see below:

    <configuration> 
        <configSections>
            <section name="ImageGenConfiguration" type="ImageGen.ImageGenConfigurationHandler,ImageGen" />
        </configSections>
        <ImageGenConfiguration configSource="config\ImageGen.config" />
    </configuration>
    

    Please confirm that the site's /config/imagegen.config file has the purchased domain key(s) in it?

    If both of the above are in place correctly, please verify the XML of the /config/imagegen.config file is valid by pasting it's contents into an online validator such as http://www.xmlvalidation.com/. I've seen problems where a subtle typo in the config file will keep it from being read correctly and thus ImageGen will ignore the file entirely, which means the domain keys wouldn't be loaded.

    Remote images are not displayed

    Please confirm the remote domain(s) are listed in the Remote Domain Whitelist of the imagegen.config file. Please don't include the http:// nor any trailing slash; just the domain itself, such as:

      <RemoteDomainWhiteList> 
          <Domain>images.example.com</Domain> 
      </RemoteDomainWhiteList> 
    

    Check the "default" class in the imgegen.config file as it may have an entry for

    There may be a typo in the imagegen.config file that makes some of the file invalid and thus ignored by ImageGen. It would be worthwhile validating the XML file with an online validator such as http://www.xmlvalidation.com/

    Images aren't the correct size

    The sample settings in the /config/imagegen.config file include maximum height and width settings in the "default" class. When running on localhost or *.local domains, or with a purchased domain key, the default class settings are applied and will limit the dimensions of the generated images. Adjust the settings in the /config/imagegen.config file to meet your needs. Full details are found in the PDF reference documentation available at http://our.umbraco.org/projects/website-utilities/imagegen

    All other problems

    Please double-check the web.config, imagegen.config, and validity of the imagegen.config's xml as described in the steps above. This often corrects many issues, especially when finding that things worked properly on one machine but not on another.

    cheers,
    doug.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 06, 2017 @ 08:53
    Ismail Mayat
    0

    Doug,

    So checking version on live site i get professional features are available for localhost and for the website domain as well.

    One thing I noticed was in the imagegen config the domain element start tag had small d I have updated that to D, however I cannot test till out of hours.

    The remote domains I have added without protocol the internal ips of the servers in the cluster, should it be external ips or hostnames?

    Once I have more information I will update futher.

    Regards

    Ismail

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Sep 06, 2017 @ 08:57
    Douglas Robar
    0

    You can use hostnames or IPs. Just be sure they are reachable from the web server since that's the machine that will make the request for the remote image.

    Here's some more info to try when you get a chance.

    Assuming the above is all correct and you're running in Professional mode, let's start by displaying one of the remote images and then add ImageGen to resize it.

    For this example I'll assume you have a web server running ImageGen Professional at http://example.com and a remote image server at http://192.168.1.1 that your web server can access but the public can't.

    On your web server, make a simple test.html page that has the following (I'm not worried about being html-strict, just enough to get the job done for testing purposes)

    <img src="/local.jpg" alt="local image" />
    <img src="http://192.168.1.1/photo.jpg" alt="remote image" />
    

    When you view http://example.com/test.html from the server you'll see both images. When viewed from public machines that don't have access to the remote image server you'll see the local image and a broken link for the remote image.

    Let's add ImageGen Professional into the mix and change the test.html file to:

    <img src="/imagegen.ashx?width=200&image=/local.jpg" alt="local image" />
    <img src="/imagegen.ashx?width=200&image=http://192.168.1.1/photo.jpg" alt="remote image" />
    

    Assuming you've allowed 192.16.1.1 as a remote domain in the imagegen.config file you should now see both images are 200 pixels wide no matter if you're viewing from the web server or from public machines.

    cheers,
    doug.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 06, 2017 @ 09:00
    Ismail Mayat
    0

    Doug,

    Just to clarify as I may have misunderstood. The 2 ips in Domain section of the config are ips of the 2 umbraco servers in the cluster. One is master the other is a slave. Not sure if that clarifies matters?

    Regards

    Ismail

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Sep 06, 2017 @ 09:25
    Douglas Robar
    0

    Hi, Ismail,

    I'm not sure! :)

    Let me put it this way... in a one-server website your webserver responds to http requests from a website visitor. ImageGen runs on that webserver and it is ImageGen that then gets the requested image, resizes and caches it, and sends it along to the website visitor.

    Even with a single webserver site you might sometimes have images hosted elsewhere that you want to resize and display. Let's say you've got images on your flickr account you want to show. Rather than link directly to the flickr images you use ImageGen to get, resize, cache, and display the remote images hosted on flickr. To do that you'd add the hostname(s) or IP(s) for the remote servers. For security you have to specify what remote locations can host images for resizing. You wouldn't want the whole world to use your website as a free 'resize any image on the internet' service. Once you've allowed the remote domain(s) your webserver can use ImageGen Professional to get, resize, and cache the flickr images you select.

    Sometimes you have multiple webservers in a load balancing arrangement. This is just like the first scenario with a single webserver. The only requirement is that ImageGen is installed on every webserver and that you don't replicate the 'cached' folders ImageGen uses; each server must be in control of its own ImageGen cache. If you don't have any remote image requests then you don't need to worry about that aspect. Everything will just work.

    Finally, with multiple webservers and remote images, you install ImageGen on all webservers, being sure you're in Professional mode on all servers, and allow remote domains for wherever the remote images are hosted. These remote images must be accessible via http(s).

    Hope this helps.

    cheers,
    doug.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 07, 2017 @ 10:36
    Ismail Mayat
    0

    Doug,

    Is the image gen cache folder stored in the media folder or somewhere else? I thought it was under App_data?

    Regards

    Ismial

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 06, 2017 @ 09:56
    Ismail Mayat
    0

    Doug,

    Ok that makes sense. I will do some more digging.

    Many thanks

    Ismail

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Sep 07, 2017 @ 11:05
    Douglas Robar
    0

    For local images, ImageGen stores its 'cached' folder where the source image resides. If you resize images stored in the /media/1234/ folder you'll find a cached folder with the resized images at /media/1234/cached/. Obviously, with Umbraco's media folder arrangement this means you'll have a lot of cached folders, making sharing the /media/ folder in a multi-server load-balanced environment difficult because each server needs to be responsible for its own 'cached' folder data. Having multiple machines updating the same cached folder data will cause a lot of problems over time.

    For remote images, the cached images are stored in the /data/cached/{remote domain}/ folder. Or, if you're running version 2.9.3 I've added the requesting server name as well, /data/cached/{servername}/{remote domain}/ which means you can safely share the /data/cached/ folder in a multi-server load-balanced environment.

    cheers,
    doug.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 07, 2017 @ 11:12
    Ismail Mayat
    1

    Doug,

    Cool. I have been liasing with client looks like whoever setup their infratructure has not done it according to the book. I have passed on load balancing docs from our. They need to get that setup and then take it from there.

    Many thanks for the pointers.

    Regards

    Ismail

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Sep 07, 2017 @ 11:14
    Douglas Robar
    0

    BTW, be sure they're running the latest version, it's a worthy upgrade even if it is 'only' a minor version number change.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Sep 07, 2017 @ 11:18
    Ismail Mayat
    0

    kk will suggest that.

Please Sign in or register to post replies

Write your reply to:

Draft