# [[Obsidian Publish Custom Domain|Custom Domains in Obsidian Publish]]
#obsidian| _Created: 2025-05-30_
[Setting up custom domains](https://help.obsidian.md/publish/domains) requires two things:
1. DNS configuration
2. Publish configuration
## DNS Configuration
You need to first set up a CNAME in the DNS record pointing to an Obsidian hostname.
This is similar to how many other publishing setups — such as GitHub Pages or Netlify — work. What is different is that you don't add a CNAME to a customized hostname for your site like `$SITEID.obsidian-publish.md`. Rather, everyone creates the same CNAME entry to `publish-main.obsidian.md`.
E.g. here is my entry in cloudflare.
![[obsidian publish custom domain cloudflare.png|center|700]]
Why is that? My guess is two reasons:
1. Your default Obsidian URL is not a hostname, it is a path on the hostname `publish.obsidian.md`. This makes it impossible to set up a CNAME directly.
2. By not giving every publish site a custom hostname, e.g. Github/Netlify does, the Obsidian team has avoided the whole infrastructure of getting a custom TLS certificate for each domain, verifying DNS delegation, etc.
For this reason, they strongly recommend Cloudflare because of their proxy feature.
![[obsidian publish CF recommendation.png|center|400]]
With this, Cloudflare handles SSL termination, SSL certificate lifecycle, and just proxies to the Obsidian hostname set up for this purpose.
>[!note] How does Obsidian Publish route Cloudflare CNAMEs?
> Since all Obsidian Publish custom DNS names have a CNAME pointing to the same Obsidian Publish host, my guess is that this host looks at the `Host` header coming from Cloudflare to map to the correct publish site. Cloudflare preserves the `Host` header sent by the original requester while proxying to the origin server.
### Non-Cloudflare options
If people don't want to use Cloudflare, there are [instructions][1] to set up proxy or redirects. Of course, you will need to do SSL termination for your custom domain yourself.
Interestingly, the URL for the redirect/rewrite is different. E.g. here is the Nginx reverse proxy configuration snippet.
```nginx
location /my-notes {
proxy_pass https://publish.obsidian.md/serve?url=mysite.com/my-notes$request_uri;
proxy_ssl_server_name on;
proxy_set_header Host publish.obsidian.md;
}
```
[1]: https://help.obsidian.md/publish/domains#Set%20up%20using%20a%20proxy
## Publish Configuration
To tie up the Obsidian side of the configuration, you need to open up the Publish configuration again (using the command palette) and specify the custom domain. This letd the Obsidian Publish service know which Publish site to serve when a request proxied from the custom domain reaches them.
You also get a chance to mention if your default Obsidian Publish site (`publish.obsidian.md/xxx`) should automatically redirect to the custom domain. To me, this was an obvious setting to enable.
---
tags: #obsidian
links: [[Obsidian Publish]]