Technical Articles & Tutorials

Vultr Object Storage With Wagtail

This quick writeup assumes you already are running dokku on vultr.

Create storage on Vultr and copy your keys.

We are available to do this type of work for you, just contact us.

dokku config:set app-name  --no-restart AWS_ACCESS_KEY_ID=aws-key-id-here
dokku config:set app-name  --no-restart AWS_SECRET_ACCESS_KEY=aws-secret-here
dokku config:set app-name  --no-restart AWS_MEDIA_URL=https://bucket-name.ewr1.vultrobjects.com
dokku config:set app-name  --no-restart AWS_S3_ENDPOINT_URL=https://ewr1.vultrobjects.com
dokku config:set app-name  --no-restart AWS_S3_CUSTOM_DOMAIN=bucket-name.ewr1.vultrobjects.com
dokku config:set app-name AWS_STORAGE_BUCKET_NAME=bucket-name
# base.py
# S3 Storage
if "AWS_STORAGE_BUCKET_NAME" in os.environ:
# https://docs.djangoproject.com/en/stable/ref/settings/#default-file-storage
MEDIA_URL = "https://%s/" % env("AWS_MEDIA_URL")
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"

AWS_STORAGE_BUCKET_NAME = env("AWS_STORAGE_BUCKET_NAME")

AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY")

# Disables signing of the S3 objects' URLs. When set to True it
# will append authorization querystring to each URL.
AWS_QUERYSTRING_AUTH = False

# Do not allow overriding files on S3 as per Wagtail docs recommendation:
# https://docs.wagtail.io/en/stable/advanced_topics/deploying.html#cloud-storage
# Not having this setting may have consequences such as losing files.
AWS_S3_FILE_OVERWRITE = False

# Default ACL for new files should be "private" - not accessible to the
# public. Images should be made available to public via the bucket policy,
# where the documents should use wagtail-storages.
AWS_DEFAULT_ACL = "public-read"

# We generally use this setting in production to put the S3 bucket
# behind a CDN using a custom domain, e.g. media.llamasavers.com.
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#cloudfront
if "AWS_S3_CUSTOM_DOMAIN" in os.environ:
    AWS_S3_CUSTOM_DOMAIN = os.environ["AWS_S3_CUSTOM_DOMAIN"]

# When signing URLs is enabled, the region must be set.
# The global S3 endpoint does not seem to support signed URLS.
# Set this only if you will be using signed URLs.
if "AWS_S3_REGION_NAME" in os.environ:
    AWS_S3_REGION_NAME = os.environ["AWS_S3_REGION_NAME"]

# This settings lets you force using http or https protocol when generating
# the URLs to the files. Set https as default.
# https://github.com/jschneier/django-storages/blob/10d1929de5e0318dbd63d715db4bebc9a42257b5/storages/backends/s3boto3.py#L217
AWS_S3_URL_PROTOCOL = os.environ.get("AWS_S3_URL_PROTOCOL", "https:")

# We generally use this setting in production to put the S3 bucket
# behind a CDN using a custom domain, e.g. media.llamasavers.com.
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#cloudfront
if "AWS_S3_CUSTOM_DOMAIN" in os.environ:
    AWS_S3_CUSTOM_DOMAIN = os.environ["AWS_S3_CUSTOM_DOMAIN"]

if "AWS_S3_ENDPOINT_URL" in os.environ:
    AWS_S3_ENDPOINT_URL = os.environ["AWS_S3_ENDPOINT_URL"]
# requirements.tx
wagtail-storages
boto3
django-storages
# Add to apps
"storages",
"wagtail_storages.apps.WagtailStoragesConfig",

Next time you deploy your app, file uploads should be stored on Vultr Object Storage.

If you have problems, you may need to change bucket permissions.

About

Why fear those copying you, if you are doing good they will do the same to the world.

Archives

  1. AI & Automation
  2. AI Filtering for Web Content
  3. Web Fundamentals & Infrastructure
  4. Reclaiming Connection: Decentralized Social Networks
  5. Web Economics & Discovery
  6. The Broken Discovery Machine
  7. Evolution of Web Links
  8. Code & Frameworks
  9. Breaking the Tech Debt Avoidance Loop
  10. Evolution of Scaling & High Availability
  11. Evolution of Configuration & Environment
  12. Evolution of API Support
  13. Evolution of Browser & Client Support
  14. Evolution of Deployment & DevOps
  15. Evolution of Real-time Capabilities
  16. The Visual Basic Gap in Web Development
  17. Evolution of Testing & Monitoring
  18. Evolution of Internationalization & Localization
  19. Evolution of Form Processing
  20. Evolution of Security
  21. Evolution of Caching
  22. Evolution of Data Management
  23. Evolution of Response Generation
  24. Evolution of Request Routing & Handling
  25. Evolution of Session & State Management
  26. Web Framework Responsibilities
  27. Evolution of Internet Clients
  28. Evolution of Web Deployment
  29. The Missing Architectural Layer in Web Development
  30. Development Velocity Gap: WordPress vs. Modern Frameworks
  31. Data & Storage
  32. Evolution of Web Data Storage
  33. Information Management
  34. Managing Tasks Effectively: A Complete System
  35. Managing Appointments: Designing a Calendar System
  36. Building a Personal Knowledge Base
  37. Contact Management in the Digital Age
  38. Project Management for Individuals
  39. The Art of Response: Communicating with Purpose
  40. Strategic Deferral: Purposeful Postponement
  41. The Art of Delegation: Amplifying Impact
  42. Taking Action: Guide to Decisive Execution
  43. The Art of Deletion: Digital Decluttering
  44. Digital Filing: A Clutter-Free Life
  45. Managing Incoming Information
  46. Cloud & Infrastructure
  47. AWS Lightsail versus EC2
  48. WordPress on AWS Lightsail
  49. Migrating from Heroku to Dokku
  50. Storage & Media
  51. Vultr Object Storage on Django Wagtail
  52. Live Video Streaming with Nginx
  53. YI 4k Live Streaming
  54. Tools & Connectivity
  55. Multi Connection VPN
  56. Email Forms with AWS Lambda
  57. Static Sites with Hexo

Optimize Your Website!

Is your WordPress site running slowly? I offer a comprehensive service that includes needs assessments and performance optimizations. Get your site running at its best!

Check Out My Fiverr Gig!

Elsewhere

  1. YouTube
  2. Twitter
  3. GitHub