Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1442 posts 3369 karma points c-trib
    Oct 23, 2015 @ 08:00
    Simon Dingley
    0

    IPublishedContent.Url Host Inconsistent when a node has multiple hostnames

    using Umbraco v7.2.8
    

    We have a large multi-language site which is load balanced across two servers and mostly works fine. One of the nodes has multiple hostnames so that we can verify the content being returned from each of the servers in the load balancer since we've had some inconsistencies in the past. So, for example we can access content on each server via

    http://live1.example.com/mynodename
    http://live2.example.com/mynodename
    

    ... as well as via

    http://www.example.com/mynodename 
    

    which will hit the load balancer and obviously return content via either live1 or live2.

    Recently some issues have come to light where one of the sites has been returning urls with the wrong hostname when we use IPublishedContent.Url. For instance when users are browsing www.example.com some of the urls being returned are being returned with the live2.example.com hostname. It doesn't appear to be consistent and at first I was questioning why it would select the live2.example.com hostname and the only reason I can guess is because it is actually the last hostname in the list on the node whereas I would have at least expected it to use the first if anything.

    In case it's relevant - which it might be we have the following enabled in the umbracoSettings.config file

    <useDomainPrefixes>true</useDomainPrefixes>
    

    Has anyone else experience anything similar before I go ahead and raise an issue on the tracker?

    Thanks, Simon

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Oct 23, 2015 @ 08:13
    Morten Bock
    0

    I think that we have sort of the same setup, but in umbraco we don't actually add the live1/live2 hostnames. Only the www one.

    In the past I have seen useDomainPrefixes only uses the configured host name on the top 2-3 levels of pages, and the rest just used the hostname of the current request. I don't know if that changed though.

    As a possible solution, you could see if your load balancer could forward the request with the www.example.com hostname, which would then make each instance ignorant of it's own special hostname, which would probably remove the issue?

  • Simon Dingley 1442 posts 3369 karma points c-trib
    Oct 23, 2015 @ 08:28
    Simon Dingley
    0

    In the past I have seen useDomainPrefixes only uses the configured host name on the top 2-3 levels of pages, and the rest just used the hostname of the current request. I don't know if that changed though.

    Not sure where the logic is in that if it is the case but I thought you may have hit on something however one of the currently affected links is level 4 but then it's not using the current hostname. If I use UrlWithDomain() it returns the correct hostname, most likely by matching the current hostname, I've not dug into the source on this yet.

    As a possible solution, you could see if your load balancer could forward the request with the www.example.com hostname, which would then make each instance ignorant of it's own special hostname, which would probably remove the issue?

    Good idea, I will check with the host as not directly involved in the management of the hosting setup.

    Thanks Morten

  • Stephen 767 posts 2271 karma points c-trib
    Oct 23, 2015 @ 12:53
    Stephen
    0

    Can you describe the exact way the domains are configured? When you get content.Url, whatever useDomainPrefix, if there are more than 1 domain defined on the same node, we have some logic to use the domain corresponding to the current url. So if you are browsing live1.com, there's no reason you should see live2.com. At all. I know it's been buggy in the past, but I'm pretty sure it is stable now. Another thing to check is... what exactly is the current (HttpContext.Current.Request.Url) during these requests - as some load balancers love to tweak the urls internally.

  • Simon Dingley 1442 posts 3369 karma points c-trib
    Oct 23, 2015 @ 13:37
    Simon Dingley
    0

    Can you describe the exact way the domains are configured?

    Sure, in IIS the site has at least 2 hostnames for each language e.g.

    • www.example.org.uk
      • example.org.uk (301-redirect to www.example.org.uk)
      • live1.example.org.uk
      • live2.example.org.uk
    • www.example.cn
      • example.cn (301-redirect to www.example.cn)
    • www.example.fr
      • example.fr (301-redirect to www.example.fr)
    • www.example.it
      • example.it (301-redirect to www.example.it)
    • www.example.nl
      • example.nl (301-redirect to www.example.nl)
    • www.example.pl
      • example.pl (301-redirect to www.example.pl)
    • www.example.com
      • example.com (301-redirect to www.example.com)

    In Umbraco the site is structured as follows for each country:

    • Site container
      • Homepage
        • Sub pages
      • Callouts

    At the Homepage level a www hostname is added for each site e.g. www.example.org.uk with the exception of the UK site which has the addition of live1.example.org.uk and live2.example.org.uk.

    In the case of the UK site the hostnames are in the following order:

    1. www.example.org.uk
    2. live1.org.uk
    3. live2.org.uk

    If there are more than 1 domain defined on the same node, we have some logic to use the domain corresponding to the current url.

    That is what I would have expected as that is of course logical :)

    Another thing to check is... what exactly is the current (HttpContext.Current.Request.Url) during these requests - as some load balancers love to tweak the urls internally.

    Typically the issue has disappeared again since this morning so I can't verify this under the same conditions as earlier right now but the current url is as expected and www.example.org.uk. Next time it comes up I will check again.

  • Simon Dingley 1442 posts 3369 karma points c-trib
    Feb 23, 2016 @ 17:01
    Simon Dingley
    0

    Another thing to check is... what exactly is the current (HttpContext.Current.Request.Url) during these requests - as some load balancers love to tweak the urls internally.

    This did happen again and I checked and the value returned by HttpContext.Current.Request.Url matched the url expected so no interference from the load balancer.

    In order to avoid this happening again in future we have been forced to implement all links using the UrlWithDomain() method instead of the Url property.

Please Sign in or register to post replies

Write your reply to:

Draft