We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45827
    • 2 Posts
    Hello;

    We developed the site for the following client http://www.host.net and have been experiencing certain (very) unique issues. First and foremost, the server error log keep getting full with the same error message:

    > PHP Notice: Undefined index: HTTP_HOST in /var/www/html/core/config/config.inc.php on line 65

    Within the error log of MODx itself in am getting tons of the following error messages as well:

    >(ERROR @ /index.php) Could not retrieve data to cache for resource "xx"

    We have done over three dozen deployments using MODx Revolution and this one deployment has been nothing but problematic. Unlike other deployments we do not have the site on our servers as the client is a cloud computing / colocation company and they are hosting it themselves. We gave them all of the specifications for the site set up which they have confirmed to have been done correctly. it must also be noted that the site has come under attack a couple of times and they have had to clear the error log and restart the server as the site was brought to its knees.

    We are not sure why were are getting these messages and would appreciate any and all direction / support / insights as to how to address them. The site was developed on MODx Revolution ver 2.2.1-pl. My developer has washed his hands on this as he cannot figure out what it is and I have had to step in as this is a very important client to us. Any and all help is greatly appreciated.

    I am including the config.inc.php below as well (having removed all site sensitive data of course):

    <?php
    /**
    * MODX Configuration file
    */
    $database_type =
    $database_server =
    $database_user =
    $database_password =
    $database_connection_charset = 'latin1';
    $dbase = 'modx';
    $table_prefix = 'modx_';
    $database_dsn = 'mysql:host=localhost;dbname=modx;charset=latin1';
    $config_options = array (
    );
    $driver_options = array (
    );

    $lastInstallTime = 1369478195;

    $site_id =
    $site_sessionname =
    $https_port = '443';
    $uuid =

    if (!defined('MODX_CORE_PATH')) {
    $modx_core_path= '/var/www/html/core/';
    define('MODX_CORE_PATH', $modx_core_path);
    }
    if (!defined('MODX_PROCESSORS_PATH')) {
    $modx_processors_path= '/var/www/html/core/model/modx/processors/';
    define('MODX_PROCESSORS_PATH', $modx_processors_path);
    }
    if (!defined('MODX_CONNECTORS_PATH')) {
    $modx_connectors_path= '/var/www/html/connectors/';
    $modx_connectors_url= '/connectors/';
    define('MODX_CONNECTORS_PATH', $modx_connectors_path);
    define('MODX_CONNECTORS_URL', $modx_connectors_url);
    }
    if (!defined('MODX_MANAGER_PATH')) {
    $modx_manager_path= '/var/www/html/manager/';
    $modx_manager_url= '/manager/';
    define('MODX_MANAGER_PATH', $modx_manager_path);
    define('MODX_MANAGER_URL', $modx_manager_url);
    }
    if (!defined('MODX_BASE_PATH')) {
    $modx_base_path= '/var/www/html/';
    $modx_base_url= '/';
    define('MODX_BASE_PATH', $modx_base_path);
    define('MODX_BASE_URL', $modx_base_url);
    }
    if(defined('PHP_SAPI') && (PHP_SAPI == "cli" || PHP_SAPI == "embed")) {
    $isSecureRequest = false;
    } else {
    $isSecureRequest = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port);
    }
    if (!defined('MODX_URL_SCHEME')) {
    $url_scheme= $isSecureRequest ? 'https://' : 'http://';
    define('MODX_URL_SCHEME', $url_scheme);
    }
    if (!defined('MODX_HTTP_HOST')) {
    if(defined('PHP_SAPI') && (PHP_SAPI == "cli" || PHP_SAPI == "embed")) {
    $http_host='www.host.net';
    define('MODX_HTTP_HOST', $http_host);
    } else {
    $http_host= $_SERVER['HTTP_HOST'];
    if ($_SERVER['SERVER_PORT'] != 80) {
    $http_host= str_replace(':' . $_SERVER['SERVER_PORT'], '', $http_host); // remove port from HTTP_HOST
    }
    $http_host .= ($_SERVER['SERVER_PORT'] == 80 || $isSecureRequest) ? '' : ':' . $_SERVER['SERVER_PORT'];
    define('MODX_HTTP_HOST', $http_host);
    }
    }
    if (!defined('MODX_SITE_URL')) {
    $site_url= $url_scheme . $http_host . MODX_BASE_URL;
    define('MODX_SITE_URL', $site_url);
    }
    if (!defined('MODX_ASSETS_PATH')) {
    $modx_assets_path= '/var/www/html/assets/';
    $modx_assets_url= '/assets/';
    define('MODX_ASSETS_PATH', $modx_assets_path);
    define('MODX_ASSETS_URL', $modx_assets_url);
    }
    if (!defined('MODX_LOG_LEVEL_FATAL')) {
    define('MODX_LOG_LEVEL_FATAL', 0);
    define('MODX_LOG_LEVEL_ERROR', 1);
    define('MODX_LOG_LEVEL_WARN', 2);
    define('MODX_LOG_LEVEL_INFO', 3);
    define('MODX_LOG_LEVEL_DEBUG', 4);
    }
    if (!defined('MODX_CACHE_DISABLED')) {
    $modx_cache_disabled= false;
    define('MODX_CACHE_DISABLED', $modx_cache_disabled);
    }
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      For one thing you need to upgrade that site. That's a relatively old version of MODx and is subject to some known security vulnerabilities. You are subscribed to the MODx security notices, I would presume?

      HTTP_HOST is supplied by the browser's HTTP headers. So if you are getting hits by a badly-written bot or browser that doesn't have it in its headers then you'll get those errors. It also won't be supplied if you are accessing via the CLI, since no browser is involved.

      The caching business seems to be a common problem with "cloud" hosting, although I occasionally get similar errors on my MAMP localhost installations, and even from time to time on MODx Cloud-hosted installations.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 3749
        • 24,544 Posts
        If the site has been hammered by bots, you might want to check out the BotBlockX plugin. http://bobsguides.com/botblockx-tutorial.html
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 45827
          • 2 Posts
          Hello;

          Thanks for both posts. We have deployed the BotBlockX and will look to upgrade the version of MODx. The client is a bit challenging so will have to schedule that.

          The site is indeed loaded unto a cloud environment - the client is a cloud computing provider. Their admin has started to set up the site on multiple servers with a VINE set up to avoid the crashes from happening. It will be interesting to see once these things are all deployed whether the issues will be mitigated...
            • 3749
            • 24,544 Posts
            There's a method described here that will let you upgrade pretty quicklyl: http://bobsguides.com/modx-upgrade-faq.html.

            Sottwell uses another method that I think would be even faster.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 28042 ☆ A M B ☆
              • 24,524 Posts
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org