We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47401
    • 295 Posts
    Recently we have been experiencing issues with a website running modx 2.x which has its own ssl cert. what we are finding is that every nower and then the base_url changes from hostname to IP address, which is causing problems with the ssl cert showing as untrusted, but also styling is lost through out the site. a quick fix seems to be clearing the modx cache, but 2 or so weeks later it happens again.

    in our apache vhost config we have the following line:

    RewriteEngine on
    RewriteCond %{SERVER_PORT}      !^443$
    RewriteRule ^/?(.*)             https://www.our-domain.co.uk/$1 [L,R]
    


    I dont think its our vhost or .htaccess that has been configured incorrectly. how can I overwrite site_url to ensure that this doesnt happen again?

    Cheers
      • 47401
      • 295 Posts
      i think i have resolved this. I added the site_url in the context and gave it the correct url i.e https://www.domain.com/

      I will continue to monitor and see if this makes a difference
      • Normally site_url is created dynamically upon every request, and it cannot just "change" itself. It can only be what the request was for. So something or somebody is requesting via IP address instead of a URL. Whether that will still be a problem for you I don't know.

        Since it's getting cached, I wonder exactly what your Manager's URL is? If someone is accessing the Manager with an IP address, then doing something that causes the cache to be cleared, then viewing the site while still using the IP address, things he views could be cached with that.
          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
          • 4385
          • 372 Posts
          I had a similar issue. I ended up just calling it uncached in my templates.
          <base href="[[!++site_url]]" />
          
            DropboxUploader -- Upload files to a Dropbox account.
            DIG -- Dynamic Image Generator
            gus -- Google URL Shortener
            makeQR -- Uses google chart api to make QR codes.
            MODxTweeter -- Update your twitter status on publish.
          • This could happen on hosts that are accessible by an IP, if the resource is cacheable but not cached, the first view will set the site_url system setting tag to the hostname the resource is accessed with. This is an IP then.

            An uncached site_url system setting tag is the best option. [ed. note: Jako last edited this post 8 years, 3 months ago.]
              • 4385
              • 372 Posts
              In my case we had a lot of old subdomain sites that were no longer available with a rule to point undefined subdomains to www. But google and other sites had old links (>3 years old) that were crawling the site hitting uncached pages and setting base href to the old subdomain.

                DropboxUploader -- Upload files to a Dropbox account.
                DIG -- Dynamic Image Generator
                gus -- Google URL Shortener
                makeQR -- Uses google chart api to make QR codes.
                MODxTweeter -- Update your twitter status on publish.
                • 47401
                • 295 Posts
                thanks all for your input. i ended up creating the site_url in the context which seemed to resole the issue.