Can I Setup a Custom Domain for My Object Storage?

Can I setup a custom domain for my Object Storage?

Sometimes you might want to use your own custom domain name instead of the rather generic ones provided by default for your S3 compatible Object Storage. The S3 Object Storage is available only via TLS encrypted transport (https) in order to improve security. CNAME resource records only work with unencrypted transport and are not supported without showing up certificate errors.


Basically, you'll need to set up a proxy server passing the requests to the S3 Object Storage system and als providing the TLS certificate. You could, for example, use Cloudflare. Please be cautious setting up such a proxy, so that it doesn't change the requests.


How do I setup a custom domain for my Object Storage?

To note the below example assumes you already have the domain setup on Cloudflare.


Also this only works for publicly shared objects.


  1. First, make sure you have created the bucket and enabled public sharing for the bucket in the Contabo Object Storage Panel.

    Note: When public sharing is enabled for a bucket, all objects inside the first level of the bucket are also automatically publicly shared (even when not shared explicitly). However, this is not true for objects in folders inside the bucket. Enable public sharing for each folder as well if you want their content to be also publicly accessible.

  2. Take note of the public sharing URL. It contains your unique tenant ID which we will need later. The URL looks like this, for example: https://eu2.contabostorage.com/5b5de0931f634e9096479dbc6e65b207:bucket.

  3. Sign into the Cloudflare Dashboard and select your domain. Go to the DNS panel first and select Add record. Choose CNAME as type, enter a name of your choice ("objects" in this example) and enter the target. This is the first part of the public sharing URL ("eu2.contabostorage.com"):


    The final DNS record should look like this:

  4. To avoid infinite redirects, set the SSL mode in Cloudflare. Go to Rules → Configuration Rules in the Cloudflare Dashboard and select Create rule. There, select "Hostname" as Field, "equals" as Operator and your hostname as Value, "objects.example.com" in our example:


  5. Scroll down to add SSL as setting and set it to "Full":

  6. Next up is a rewrite rule to shorten the final URL. Go to Rules → Transform Rules in the Cloudflare Dashboard, select Create transform rule and Rewrite URL:

    We set the rule to match all requests for the newly-added hostname so select "Hostname" as Field, "equals" as Operator and your hostname as Value, "objects.example.com" in our example.

  7. Select Rewrite to... as Then... action, make sure it is set to "Dynamic" and enter this pattern:

    concat("/<your unique tenant ID>:<bucket>",http.request.uri.path)


    With this rewrite rule, we won't need to put the tenant ID and bucket name in the URL anymore. Cloudflare will do it for us when proxying the request to the Object Storage. With this, we went from the long original URL https://eu2.contabostorage.com/5b5de0931f634e9096479dbc6e65b207:bucket/image.jpg to a much shorter: https://objects.example.com/image.jpg.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article

Modified on 25 Mar 2024

Can’t find what you’re looking for?

Get in Touch

Do you have a pre-sales question?