Change the Base URL to https

Silverstripe Version:4.0

I am using SIlverstripe behind an AWS ALB which works for the main HTML page but the tag contains a http:// address instead of https://.
Therefore all of the JS and CSS are being served over HTTP and Chrome is throwing all sorts of errors.
How do I change this base tag to point to the https:// url? Is this done in nginx?

1 Like

The best way I have found to work around this is to do the following -

  1. Set an environment variable for SS_BASE_URL, so in your .env file or server environment settings you can add -

     SS_BASE_URL="https://yourdomain.com"
    
  2. Then in your sites _config yml files (mine is in mysite.yml) you can add the following -

     SilverStripe\Control\Director:
       alternate_base_url: '`SS_BASE_URL`'
    

This will then force SS to use that https domain for all possible link generation etc.

I’ve got a similar situation and added alternate_base_url in mysite.yml but found the config needs to run before the framework config and before the Director class does it’s thing else alternate base url isn’t set in time for protocol and url to be generated from the desired url.

    ---
    Name: customconfig
    Before:
      - '#framework'
    ---
    SilverStripe\Control\Director:
      alternate_base_url: '`SS_BASE_URL`'