Do you want to use Google Storage for your image uploads? Here are the steps:
Set a default Google project if you don’t have one.
Get a developer key.
Create a bucket by going here. Enter a unique name and select a default storage class (I used multi-regional within the US).
Now we need to configure the Discourse instance. Go to settings, and add a filter for S3. Then make the changes below:
Check the “
enable s3 backups” checkbox if you want to activate manual or automated backups
Enter the desired bucket name created above in “
s3 backup bucket” if
enable s3 backupsis checked
Paste in both “
Access Key ID” and “
Secret Access Key” in their respective text fields (these were generated when the developer key was created)
s3_endpoint, paste in the below endpoint:
That’s it! Try uploading an image - it should all work magically
To ‘serve’ images directly from your domain, follow the steps below:
Make sure your bucket is accessible publicly. It needs to set up using object level permissions though
Set up a load balancer if you don’t already have one. For the backend, create a backend bucket, point it to the storage bucket created above, enable CDN, and connect it
For the URL map, create two rules. Hosts for both need to be
*; paths need to be
/optimized/*; and the backend needs to point to the backend bucket - save the settings
In Discourse settings, change the
s3 cdn url toyour domain - make sure this ties in with how your load balancer rule has been set up
That’s it - the images should now come from
- Go to your project in Google Cloud Console
- Select Storage
- Select your bucket
- Go to the permissions tab
- Add new permission, fill your service account email with your account. for roles, select Storage Legacy Object Owner
- Save and done.