Change the Base URL to https


#1

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?


#2

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.