{"id":22229,"date":"2024-09-23T15:59:07","date_gmt":"2024-09-23T13:59:07","guid":{"rendered":"https:\/\/contabo.com\/blog\/kb\/103000282942-can-i-setup-a-custom-domain-for-my-object-storage\/"},"modified":"2025-04-10T18:05:10","modified_gmt":"2025-04-10T16:05:10","slug":"103000282942-can-i-setup-a-custom-domain-for-my-object-storage","status":"publish","type":"kb","link":"https:\/\/contabo.com\/blog\/kb\/103000282942-can-i-setup-a-custom-domain-for-my-object-storage\/","title":{"rendered":"Can I Setup a Custom Domain for My Object Storage?"},"content":{"rendered":"<h4 dir=\"ltr\"><strong dir=\"ltr\">Can I setup a custom domain for my Object Storage?<\/strong><\/h4>\n<p dir=\"ltr\">Sometimes you may 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 only available 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.<\/p>\n<p dir=\"ltr\">Basically, <strong>you&#8217;ll need to set up a proxy server that passes requests to the S3 Object Storage system and also provides the TLS certificate.<\/strong> You could use Cloudflare, for example. Please be careful when setting up such a proxy so that it doesn&#8217;t modify the requests.<\/p>\n<p dir=\"ltr\"><\/p>\n<h4 dir=\"ltr\"><strong>How do I setup a custom domain for my Object Storage?<\/strong><\/h4>\n<p dir=\"ltr\">To note the example below assumes you already have your domain set up on Cloudflare.<\/p>\n<p dir=\"ltr\"><\/p>\n<p dir=\"ltr\">Also, <strong>this only works for publicly shared objects.<\/strong><\/p>\n<p dir=\"ltr\"><\/p>\n<ol>\n<li dir=\"ltr\">First, make sure you have created the bucket and enabled public sharing for the bucket in the Contabo Object Storage panel.\n<p>Note: When public sharing is enabled for a bucket, all objects within the first level of the bucket are automatically publicly shared (even if they are not explicitly shared). However, this is not true for objects in folders inside the bucket. Also enable public sharing for each folder if you want its contents to be publicly accessible.<\/p>\n<\/li>\n<li dir=\"ltr\">Take note of the public sharing URL. It contains your unique tenant ID, which you will need later. The URL should look like this: <a data-fr-linked=\"true\" href=\"https:\/\/eu2.contabostorage.com\/5b5de0931f634e9096479dbc6e65b207:bucket\" rel=\"nofollow nofollow\">https:\/\/eu2.contabostorage.com\/5b5de0931f634e9096479dbc6e65b207:bucket<\/a>.\n<\/li>\n<li dir=\"ltr\">Login to the <u><a href=\"https:\/\/dash.cloudflare.com\/\" rel=\"noopener noreferrer nofollow nofollow\" target=\"_blank\"><u>Cloudflare Dashboard<\/u><\/a><\/u> and select your domain. First, go to the DNS panel first and select <em>Add record<\/em>. Select <em>CNAME<\/em> as the type, enter a name of your choice (&#8220;objects&#8221; in this example) and enter the target. This is the first part of the public sharing URL (&#8220;eu2.contabostorage.com&#8221;):\n<p><img decoding=\"async\" src=\"https:\/\/s3-eu-central-1.amazonaws.com\/euc-cdn.freshdesk.com\/data\/helpdesk\/attachments\/production\/103098339269\/original\/aZuLuS6MC13V-n8acATxgERbYMPos2oSYg.png?1710926557\" class=\"fr-fil fr-dib\" data-attachment=\"[object Object]\" data-id=\"103098339269\" alt=\"Search DNS records\"><br \/>The final DNS record should look like this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s3-eu-central-1.amazonaws.com\/euc-cdn.freshdesk.com\/data\/helpdesk\/attachments\/production\/103098340004\/original\/yOgfk_mDBmvc8tXp-7lIOfb671yXA4UcOw.png?1710926626\" class=\"fr-fil fr-dib\" data-attachment=\"[object Object]\" data-id=\"103098340004\" alt=\"Example DNS record\"><\/li>\n<li dir=\"ltr\">To avoid infinite redirects, set Cloudflare to SSL mode. In the Cloudflare dashboard, go to Rules &rarr; Configuration Rules and select Create Rule. Select &#8220;hostname&#8221; as the field, &#8220;equals&#8221; as the operator, and your hostname as the value, &#8220;objects.example.com&#8221; in our example:<br \/><img decoding=\"async\" class=\"fr-fil fr-dib\" data-attachment=\"[object Object]\" data-id=\"103098340391\" src=\"https:\/\/s3-eu-central-1.amazonaws.com\/euc-cdn.freshdesk.com\/data\/helpdesk\/attachments\/production\/103098340391\/original\/5FYtIJhxE1YXxtb8Jztf-vbEYpGH2Leo4Q.png?1710926660\" alt=\"Example configuration rules\"><\/li>\n<li dir=\"ltr\">Scroll down to the add SSL setting and set it to &#8220;Full&#8221;:\n<p><img decoding=\"async\" src=\"https:\/\/s3-eu-central-1.amazonaws.com\/euc-cdn.freshdesk.com\/data\/helpdesk\/attachments\/production\/103098340694\/original\/rQsOspN6f6nvaoO4IkpUS3Z-1zdrkngj7A.png?1710926700\" class=\"fr-fil fr-dib\" data-attachment=\"[object Object]\" data-id=\"103098340694\" alt=\"Select SSL\/TLS encryption mode set to Full\"><\/li>\n<li dir=\"ltr\">Next, create a rewrite rule to shorten the final URL. Go to Rules &rarr; Transform Rules in the Cloudflare dashboard and select Create Transform Rule and Rewrite URL:<br \/><img decoding=\"async\" class=\"fr-fil fr-dib\" data-attachment=\"[object Object]\" data-id=\"103098341086\" src=\"https:\/\/s3-eu-central-1.amazonaws.com\/euc-cdn.freshdesk.com\/data\/helpdesk\/attachments\/production\/103098341086\/original\/OHJtR_urfLyUyMXCa52sb2Y4OTvRwhLwgQ.png?1710926736\" alt=\"Create transform rule dropdown\"><br \/>We set the rule to match all requests for the newly added hostname, so we choose &#8220;hostname&#8221; as the field, &#8220;equals&#8221; as the operator, and your hostname as the value, which is &#8220;objects.example.com&#8221; in our example.\n<\/li>\n<li dir=\"ltr\">Select <em>Rewrite to&#8230;<\/em> as <em>Then&#8230;<\/em> action, make sure it is set to &#8220;Dynamic&#8221; and enter this:\n<p>concat(&#8220;\/&lt;your unique tenant ID&gt;:&lt;bucket&gt;&#8221;,http.request.uri.path)<\/p>\n<p><img decoding=\"async\" class=\"fr-fil fr-dib\" data-attachment=\"[object Object]\" data-id=\"103098341752\" src=\"https:\/\/s3-eu-central-1.amazonaws.com\/euc-cdn.freshdesk.com\/data\/helpdesk\/attachments\/production\/103098341752\/original\/hUpRQZByQuLsa215DKS7HxARAb5A4ozsxw.png?1710926797\" alt=\"Setting Rewrite to Dynamic and example\"><br \/>With this rewrite rule, we don&#8217;t need to include the tenant ID and bucket name in the URL anymore. Cloudflare will do that for us when proxying the request to the Object Storage. So we went from the original long URL https:\/\/eu2.contabostorage.com\/5b5de0931f634e9096479dbc6e65b207:bucket\/image.jpg to a much shorter one: <a href=\"https:\/\/objects.example.com\/image.jpg\" rel=\"nofollow nofollow\">https:\/\/objects.example.com\/image.jpg<\/a>.<\/li>\n<\/ol>\n<p><span class=\"ast-load-more active\"><a href=\"https:\/\/help.contabo.com\/en\/support\/solutions\/articles\/103000282942-can-i-setup-a-custom-domain-for-my-object-storage-\" rel=\"nofollow\">Details&#8230;<\/a> <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Can I setup a custom domain for my Object Storage? Sometimes you may 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 only available via TLS encrypted transport (https) in order to improve security. CNAME resource [&hellip;]<\/p>\n","protected":false},"author":72,"featured_media":0,"template":"","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[2067],"tags":[],"class_list":["post-22229","kb","type-kb","status-publish","hentry","category-kb"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Contabo Web","author_link":"https:\/\/contabo.com\/blog\/author\/julius-nalivaiko\/"},"uagb_comment_info":0,"uagb_excerpt":"Can I setup a custom domain for my Object Storage? Sometimes you may 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 only available via TLS encrypted transport (https) in order to improve security. CNAME resource&hellip;","_links":{"self":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/users\/72"}],"version-history":[{"count":1,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22229\/revisions"}],"predecessor-version":[{"id":22915,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22229\/revisions\/22915"}],"wp:attachment":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/media?parent=22229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/categories?post=22229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/tags?post=22229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}