We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24719
    • 194 Posts
    Hi,

    I’ve got an odd problem. On a site with multiple templates that all use <base href="[(site_url)]" />, one template (the main one) just won’t expand the placeholder with the site host name. The placeholder is just replaced with ’http:///’.

    It’s really odd. If i check phpinfo on the server, $_SERVER[’HTTP_HOST’] is set correctly.

    I’m racking my brains on this one. Anyone any ideas? I don’t want to just hard-code the host name or it’ll mess up testing and development, plus I can’t see any reason why it shouldn’t work...

    Cheers
      • 24719
      • 194 Posts
      i’ve fixed this. i don’t know why it was happening, but it was only happening on the front page of the site. very odd...
        • 22303 MODX Staff
        • 10,725 Posts
        redman:

        Did you change anything? Also, what version of MODx are we discussing and what is the Apache/PHP/MySQL configuration? I’ve experienced something similar in some rare situations and am wondering if you adjusted anything at all before it went away. It seems to happen sometimes after refreshing the cache, as if the first access to that page is coming from a client that is not setting the http_host to the proper value, but I could never confirm this.
          • 24719
          • 194 Posts
          To fix it I edited manager/includes/config.inc.php:
          $site_url .= (!empty($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : 'www.myhost.com';
          


          I agree, it seems like the first access to page doesn’t set the $_SERVER[’HTTP_HOST’] variable properly. I’ve no idea why...
            • 22303 MODX Staff
            • 10,725 Posts
            This sounds like a load-balancing issue (since you PM’d me that it was in a load balancing configuration). Can you tell me how the load-balancing is configured?
              • 24719
              • 194 Posts
              it’s just set up using a round-robin algorithm. Nothing that special...
                • 22303 MODX Staff
                • 10,725 Posts
                Quote from: redman at Sep 25, 2008, 08:38 AM

                it’s just set up using a round-robin algorithm. Nothing that special...
                Any documentation, software, or other information that describes this round-robin technique?  Sorry, I have no experience with load balancing and do not know how it is accomplished.  But I want to find out why HTTP_HOST is empty sometimes when using it.
                  • 24719
                  • 194 Posts
                  Round robin just means that traffic is passed around all the hosts equally. The load balancer doesn’t attempt to determine the actual load on servers before sending traffic to it, so if one particular request causes a high load on a server, the load balancer won’t send more traffic to other servers until it recovers. It’ll just keep on distributing traffic equally to all servers.

                  I don’t have any documentation on the actual load balancer we’re using...
                    • 22303 MODX Staff
                    • 10,725 Posts
                    Well, until I know what software/hardware configuration is being used to handle the load balancing, it’s gonna be difficult to determine the problem. I’ll try and start an in-depth investigation with the admin of the servers we have in a similar configuration.
                      • 25663 MODX Staff
                      • 12,272 Posts
                      Round robin load balancing can be done simply with DNS A-Record entries, so there may be no real HW involved. DNS Made Easy works this way in conjunction with EC2, for example (would be public IPs of course):

                      mysite.com A 192.168.10.1
                      mysite.com A 192.168.10.2
                      mysite.com A 192.168.10.3
                      mysite.com A 192.168.10.4
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me